Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何导入vue js组件?_Javascript_Vue.js - Fatal编程技术网

Javascript 如何导入vue js组件?

Javascript 如何导入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

我有两个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'{
数据:函数(){
},
模板:`
单击以编辑学生
//在此处使用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项目