Javascript 如何导入vue js组件?
我有两个js文件students.js和modal.js。如何在students.js中导入modal.js中的组件? 我的学生.jsJavascript 如何导入vue js组件?,javascript,vue.js,Javascript,Vue.js,我有两个js文件students.js和modal.js。如何在students.js中导入modal.js中的组件? 我的学生.js Vue.component('student', { data: function(){ }, template:` <h1>Click to edit students</h1> // use modals.js component here.......... ` }) Vue.component('student
Vue.component('student', {
data: function(){
},
template:`
<h1>Click to edit students</h1>
// use modals.js component here..........
`
})
Vue.component('student'{
数据:函数(){
},
模板:`
单击以编辑学生
//在此处使用modals.js组件。。。。。。。。。。
`
})
my modals.js
Vue.component('modal', {
template:`
<h1>This is modal.</h1>`
})
Vue.component('modal'{
模板:`
这是模态的`
})
您可以使用导入。有关更多信息:
import ComponentA from./ComponentA'
从“./ComponentC”导入ComponentC
导出默认值{
组成部分:{
成分a,
成分C
},
// ...
}
全局注册该组件,以便您可以在任何其他组件中直接使用它。像这样:
Vue.component('student'{
数据:函数(){
},
模板:`
单击以编辑学生
//在此处使用modals.js组件。。。。。。。。。。
..//这不适用于使用CDN设置的vue项目