实现局部组件的注册功能,样例如下
代码如下
<html><head><meta charset="utf-8"><title></title></head><body><div id="app"><hello-word></hello-word><hello-tom></hello-tom></div><script src="js/vue.js"></script><script>//局部组件注册var HelloWord = {data: function() {return {msg:'HelloWord'}},template:'<div>{{msg}}</div>'}var HelloTom = {data: function() {return {msg:'HelloTom'}},template:'<div>{{msg}}</div>'}var vm = new Vue({el: '#app',data: {},components: {'hello-word':HelloWord,'hello-tom':HelloTom}})</script></body>
</html>