- 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.
推薦閱讀
- Web Scraping with Python
- 無代碼編程:用云表搭建企業數字化管理平臺
- Vue.js 3.0源碼解析(微課視頻版)
- Groovy for Domain:specific Languages(Second Edition)
- 用戶體驗增長:數字化·智能化·綠色化
- The Complete Coding Interview Guide in Java
- 移動界面(Web/App)Photoshop UI設計十全大補
- Julia高性能科學計算(第2版)
- Instant GLEW
- Using Yocto Project with BeagleBone Black
- 分布式系統架構與開發:技術原理與面試題解析
- Python機器學習
- Mastering R for Quantitative Finance
- Serverless從入門到進階:架構、原理與實踐
- 精通Oracle 12c 數據庫管理