文章詳情頁(yè)
javascript - Vue.component的問(wèn)題,幫忙解答一下~
瀏覽:82日期:2022-11-30 09:15:06
問(wèn)題描述
Vue.component(name,obj);我看vue官網(wǎng)上市這樣寫的Vue.component(’my-component’, { template: ’<p>A custom component!</p>’})注冊(cè)一個(gè)全局的模板,<my-component><my-component>
能不能不直接在template寫代碼,而是引用寫好的.vue文件。做my-component的template??? 能的話 要怎么寫???
問(wèn)題解答
回答1:1.官網(wǎng)上的代碼使用于前端非工程化開發(fā)中,比較簡(jiǎn)單的模式
2.進(jìn)階的話,也就是使用vue文件,進(jìn)行編譯咯喲。更多參考vue-cli 生成的 template
import Hello from './hello.vue';
hello.vue
<template><p></p></template><script></script>
標(biāo)簽:
JavaScript
排行榜

熱門標(biāo)簽