Home  >  Article  >  Web Front-end  >  How to assign values ​​to object properties in vue.js

How to assign values ​​to object properties in vue.js

coldplay.xixi
coldplay.xixiOriginal
2020-11-27 11:59:4610940browse

vue.js method of assigning values ​​to object attributes: first introduce the vue file and modify the content of the title tag; then insert statements in the tag; then call the [created()] function; and finally in [mounted()] Reassign the properties of the obj object.

How to assign values ​​to object properties in vue.js

The operating environment of this tutorial: Windows 7 system, Vue version 2.9.6, Dell G3 computer.

Vue.js method of assigning values ​​to object properties:

The first step is to introduce the vue.js file and modify the title tag content in the new Web project. As shown in the figure below:

How to assign values ​​to object properties in vue.js

The second step is to insert <template in the><code> tag ;, and insert

How to assign values ​​to object properties in vue.js

##The third step, use export default, Instantiate the vue object and assign an initial value to stitle, as shown in the following figure:

How to assign values ​​to object properties in vue.js

The fourth step is to call the

created() function, and Use the Object.assign() method to assign values ​​to the snames in the object, as shown in the following figure:

How to assign values ​​to object properties in vue.js

The fifth step is to save the code and open the browser Check the print result on the server console and find that there is a syntax error, as shown in the following figure:

How to assign values ​​to object properties in vue.js

The sixth step is to modify the code and add the object obj to data, and then

mounted()Reassign the obj object attributes, as shown below:

How to assign values ​​to object properties in vue.js

Related free learning recommendations:

javascript(video)

The above is the detailed content of How to assign values ​​to object properties in vue.js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn