建立 组建.vue
先在components
文件夹下建立一个my
建立组建Con.vue
<template>
<v-btn elevation="2">{{msg}}</v-btn>
</template>
<script>
export default {
data () {
return {
msg:"click"
}
}
};
</script>
<style>
</style>
配置路由
router的index.js
import Con from '@/components/my/Con'
和
{
path:'/Con',
name :'Con',
component: Con
}
引用组建
<Con/>
和
import Con from "./my/Con.vue";
components: {
Con : Con,
},
<template>
<div class="hello">
<Con/>
</div>
</template>
<script>
import Con from "./my/Con.vue";
export default {
name: "HelloWorld",
data() {
return {
msg: "Welcome to Your Vue.js App",
};
},
components: {
Con : Con,
},
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>