[Vue] Two ways of writing el and data respectively

elThe first way of writing: object style

elThe second way of writing: Mounting method of prototype object

Variables starting with $ are programmer-oriented variables and methods.
Methods and properties on the instance prototype object, and Prototype is the prototype object.

model_Vue.$mount("#prj")

$mount is the mounting method, Vueconnecting the container and the instance.

dataThe first way to write object form

dataThe second way of writing is functional expression

Write data as a function and must return an object. The object data is the required

const model_Vue = new Vue({
    
    
    el: '#model',
    data:function(){
    
    
        return {
    
    
            modelChoiceTitleContent: "作品展示"
        }
    }
})

VueCall this function and call console.log(this)Discovery thisto be Vuean instance object

Note: It is required to be an ordinary function, not an anonymous function. The anonymous (arrow) function thisis window, and Vuethe managed functions are required to be written as ordinary functions.

data:function(){...}abbreviationdata(){...}

Guess you like

Origin blog.csdn.net/m0_50939789/article/details/128460755