- 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.
推薦閱讀
- 程序員面試白皮書
- 潮流:UI設(shè)計必修課
- Apache Spark 2.x Machine Learning Cookbook
- oreilly精品圖書:軟件開發(fā)者路線圖叢書(共8冊)
- Full-Stack Vue.js 2 and Laravel 5
- Python編程實戰(zhàn)
- Visual Basic程序設(shè)計
- Learning Concurrency in Kotlin
- Unity 3D/2D移動開發(fā)實戰(zhàn)教程
- Odoo 10 Implementation Cookbook
- Python期貨量化交易實戰(zhàn)
- TypeScript 2.x By Example
- Mastering HTML5 Forms
- Instant Apache Camel Messaging System
- Hands-On Data Visualization with Bokeh