<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>demo</title>
</head>
<body>
<div id="app">
<vue-base></vue-base>
</div>
<script src="vue.js"></script>
<script>
var base = Vue.extend({
template: '<h1>{{data}}</h1>',
data(){
console.log('ok')
return {data: 'hello vue'}
}
})
var app = new Vue({
el: '#app',
components:{
'vue-base': base
}
})
</script>
</body>
</html>
为什么会打印2次 ok? 1.0.21版本 1.0.16版本是好的 就调用一次
这是之前版本的bug,作者已经修复,看 Changelog 或者 当时的issue