安装vue
cnpm i -g @vue/cli
cnpm i -g @vue/cli-service-global
创建基本文件
- main.js
import Vue from 'vue';
import App from './App';
new Vue({
el: '#app',
render: h => h(App)
})
- App.vue
<template>
<div>
<labelx :t="2">你好,中国</labelx>
</div>
</template>
<script>
import labelx from './component/label.js'
export default {
components: {
labelx
}
}
</script>
- label.js
export default {
props: {
t: {}
},
render() {
let tag = 'h' + this.t;
return (
<tag>{this.$slots.default}</tag>
)
}
}