當用vue-cli創建一個項目后,
創建項目的方法:?https://www.cnblogs.com/fps2tao/p/9376847.html
編寫了組件怎么,在其他組件中調用了?
組件listBox: 路徑 src/components/listBox.vue
<template><div class="listBox">listBox222</div> </template><script> export default {name: "listBox",data:function(){return {}} } </script><style scoped></style>
?
1.全局組件注冊 復用
mian.js文件
import listBox from './components/listBox'//全局組件注冊 Vue.component('listBox',listBox);
?
?
2.局部組件注冊 復用
在要使用的組件中 引用 將要調用的組件
比如在App.vue中使用listBox 那么,App.vue下發如下:
<template><div id="app"><img src="./assets/logo.png"><router-view/><listBox></listBox></div> </template><script> import listBox from './components/listBox'export default {name: 'App',components:{'listBox':listBox} } </script><style> #app {font-family: 'Avenir', Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;color: #2c3e50;margin-top: 60px; } </style>
?
?