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

208
Views
El componente de archivo único en vuejs3 no funciona

Traté de aprender vuejs con una aplicación Symfony. tengo un problema que no entiendo...

Con un archivo "normal" products.js

 import { createApp, h } from 'vue'; const template = '<h1>Hello {{firstName }}! </h1>' const app = createApp({ data() { return { firstName: 'test', } }, template: template }).mount('#app') window.app = app;

El código anterior me muestra 'Hello test' en mi index.html.twig

Quiero hacerlo en un solo componente de archivo porque me gusta, pero con el código a continuación, no me muestra nada. La advertencia es:

[Vue warn]: Component is missing template or render function. at <Products> at <App>

productos.js

 import { createApp, h } from 'vue'; import { createWebHashHistory, createRouter } from "vue-router"; // components import App from './pages/products'; const app = createApp({}); app.component('products', App); // Router const router = createRouter({ history: createWebHashHistory(), routes: [ { path: "/", component: App }, ], }); app.use(router); app.config.devtools = true app.mount('#app')

páginas/productos.vue

 <template> <h1>Hi !</h1> </template> <script> export default { name: 'Products', }; </script>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Incluso con una forma sencilla de mostrar algo.

 import { createApp } from 'vue'; // components import App from './pages/products.vue'; const app = createApp({}) app.component('products', App) app.mount('#app')

o solo

 import { createApp } from 'vue'; // components import App from './pages/products.vue'; createApp(App).mount('#app')

Tengo la misma advertencia y no muestra nada en mi navegador.

about 4 years ago · Juan Pablo Isaza Report

0

FUNCIONA !

Simplemente elimino el loader: 'vue-loader' en mi paquete web (tengo .addLoader({test: /\.vue$/,}) ) config, ¡entonces puedo ver mi plantilla! (Pero no entiendo por qué...)

about 4 years ago · Juan Pablo Isaza 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!