问 题
vue1中,el属性可以是标签,id,如:
testnew Veu({
el:"html"
});
目的是接收html内部所有的标签
然而2.0却只能用id,并且body内部的id
new Veu({
el:"#app"
});
是我姿势不对,还是2.0改变了绑定方式?
解决方案
Vue 2.0 中源码如下:
src/entries/web-runtime-with-compiler.js
el = el && query(el)
/* istanbul ignore if */
if (el === document.body || el === document.documentElement) {
process.env.NODE_ENV !== 'production' && warn(
`Do not mount Vue to or
- mount to normal elements instead.`)
return this
}
query方法来着src/platforms/web/util/index.js
源码如下:
/**
* Query an element selector if it's not an element already.
*/
expor