您的位置:首頁技術文章
文章詳情頁

javascript - Vue.component的問題,幫忙解答一下~

瀏覽:99日期:2022-11-30 09:15:06

問題描述

Vue.component(name,obj);我看vue官網上市這樣寫的Vue.component(’my-component’, { template: ’<p>A custom component!</p>’})注冊一個全局的模板,<my-component><my-component>

能不能不直接在template寫代碼,而是引用寫好的.vue文件。做my-component的template??? 能的話 要怎么寫???

問題解答

回答1:

1.官網上的代碼使用于前端非工程化開發中,比較簡單的模式

2.進階的話,也就是使用vue文件,進行編譯咯喲。更多參考vue-cli 生成的 template

import Hello from './hello.vue';

hello.vue

<template><p></p></template><script></script>

標簽: JavaScript
国产综合久久一区二区三区