Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
¿Por qué el mensaje de alerta JS no se activa cuando está en clase?

Estoy aprendiendo desarrollo de complementos de wordpress. Tengo una pregunta ficticia: ¿por qué el mensaje de alerta no se activa cuando se encuentra en la clase js o en index.js?

Creé un nuevo archivo "test.php" en mi carpeta de complementos

 <?php /* Plugin Name: Test Description: test plugin Version: 1.0 Author: Jarda */ class Test{ function __construct(){ add_action('wp_enqueue_scripts', array($this, 'startMyScripts')); } function startMyScripts(){ wp_enqueue_script( 'testScript', plugin_dir_url( __FILE__ ) . '/src/index.js' ); } $test = new Test(); }

Entonces creé el archivo js "index.js" en /src/

 import Search from "./modules/Search" const search = new Search()

Y una clase "Buscar" en /src/modules

 class Search{ constructor(){ alert("helo") console.log("fired") } } export default Search

Tengo un nodo instalado, el archivo package.json se ve así

 { "name": "test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "build": "wp-scripts build", "start": "wp-scripts start", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "@wordpress/scripts": "^23.5.0" } }
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Bien, entonces la ruta debe ser wp_enqueue_script( 'testScript', plugin_dir_url( FILE ) . '/build/index.js' );

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!