vue控制台报错:Vue is a constructor and should be called with the “new” keyword
没用new,会报错
Vue({
el: '.root',
data: {
info: 'Hello,World!',
}
});
原因:判断function Vue(){}里的this是不是vue的实例对象。
function Vue (options) {
if (!(this instanceof Vue)
) {
warn('Vue is a constructor and should be called with the `new` keyword');
}
this._init(options);
}