我想将具有多个vue组件的文件中的特定Vue组件导入另一个组件文件
我已经尝试了从'./components/SeveralComponents的普通导入组件,但是没有用
Vue.component('firstComponent', {
props: [a,b,c],
template: <p>hello world</p>
});
Vue.component('secondComponent', {
props: [c,d,e],
template: <h1> heading1 </h1>
});
<div>
<secondComponent></secondComponent>
</div>
export default {
name: 'SeveralComponents',
data() {
},
methods: {
method1() {
}
如何将firstComponent导入另一个组件文件?
我希望只有第一个组件
您可以使用命名的导出导出options对象,然后在另一步中向Vue注册该对象。
然后将命名的导出导入到客户端文件中。
export const firstComponent = {
props: [a,b,c],
template: <p>hello world</p>
}
Vue.component('firstComponent', firstComponent);
import {firstComponent} from 'MultiComponent.vue'
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句