使用js封装vue组件,可以发布到npm
var Child = {
template: '<div>A custom component! {{msg + "----" + title + "-----" + content}}</div>',
props: ['title', 'content'],
data: function() {
return {
msg: '子组件本身的数据'
}
},
}
export default Child
<template>
<child :title="'我是标题'" :content="'我是内容'"></child>
</template>
<script>
import Child from './component.js'
export default {
components: {
Child
},
}
</script>