- Vue.js 2 Web Development Projects
- Guillaume Chau
- 120字
- 2021-07-02 22:34:31
The template option
If you look in the index.html file, you will see that the #app element is already there and empty. In fact, we won't write anything inside. Instead, we will use the template option directly on the definition object. Let's try it with a dumb template:
new Vue({
name: 'game',
el: '#app',
template: `<p id="#app">
Hello world!
</p>`,
})
Here, we used the new JavaScript strings, with the ` character (back quote). It allows us, among other things, to write text spanning multiple lines, without having to write verbose string concatenations.
Now if you open the app, you should see the 'Hello world!' text displayed. As you guessed, we won't inline the template in the #app element going forward.
推薦閱讀
- Vue.js 3.x快速入門
- Google Apps Script for Beginners
- SoapUI Cookbook
- INSTANT FreeMarker Starter
- VSTO開發入門教程
- MySQL數據庫管理與開發(慕課版)
- 用Flutter極速構建原生應用
- PostgreSQL Replication(Second Edition)
- 精通MATLAB(第3版)
- JavaScript程序設計(第2版)
- MySQL程序員面試筆試寶典
- Python 3 Object:oriented Programming(Second Edition)
- Unity Android Game Development by Example Beginner's Guide
- Backbone.js Patterns and Best Practices
- 編程風格:程序設計與系統構建的藝術(原書第2版)