[圖片上傳中...(3019156f-c147-39b1-a9c4-7bdb6f291897.png-c4bdc6-1562388468600-0)]
屬性:
vm.$el
獲取Vue實例關(guān)聯(lián)的DOM元素;
vm.$data
獲取Vue實例的data選項(對象)
vm.$options
獲取Vue實例的自定義屬性(如vm.$options.methods,獲取Vue實例的自定義屬性methods)
vm.$refs
獲取頁面中所有含有ref屬性的DOM元素(如vm.$refs.hello,獲取頁面中含有屬性ref = “hello”的DOM元素,如果有多個元素,那么只返回最后一個)
Js代碼
var app = new Vue({
el:"#container",
data:{
msg:"hello,2018!"
},
address:"長安西路"
})
console.log(app.$el);
返回Vue實例的關(guān)聯(lián)DOM元素,在這里是#container
console.log(app.$data);
返回Vue實例的數(shù)據(jù)對象data,在這里就是對象{msg:”hello,2018“}
console.log(app.$options.address);
返回Vue實例的自定義屬性address,在這里是自定義屬性address
console.log(app.$refs.hello)
返回含有屬性ref = hello的DOM元素(如果多個元素都含有這樣的屬性,只返回最后一個)<h3 ref = "hello">呵呵 1{{msg}}</h3>
轉(zhuǎn)載:https://forlan.iteye.com/blog/2418359