Use el option to specify a template
<!DOCTYPE html>
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< meta name = " viewport" content = " width=device-width, initial-scale=1.0" >
< meta http-equiv = " X-UA-Compatible" content = " ie=edge" >
< title> Document</ title>
</ head>
< body>
< div id = " app" >
< h1> {{greeting}}</ h1>
< input type = " text" v-model = " greeting" >
</ div>
< script src = " ./vue.js" > </ script>
< script>
const app = new Vue ( {
el: '#app' ,
data: {
greeting: 'Hello Vuejs'
}
} ) ;
</ script>
</ body>
</ html>
Use template option to specify a template to be mounted - inline template
<!DOCTYPE html>
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< meta name = " viewport" content = " width=device-width, initial-scale=1.0" >
< meta http-equiv = " X-UA-Compatible" content = " ie=edge" >
< title> Document</ title>
</ head>
< body>
< div id = " app" > </ div>
< script src = " ./vue.js" > </ script>
< script>
const app = new Vue ( {
el: '#app' ,
template: '<div><h1>{{greeting}}</h1></div>' ,
data: {
greeting: 'Hello Vuejs'
}
} ) ;
</ script>
</ body>
</ html>
Use template option to specify a template to be mounted - separate template
<!DOCTYPE html>
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< meta name = " viewport" content = " width=device-width, initial-scale=1.0" >
< meta http-equiv = " X-UA-Compatible" content = " ie=edge" >
< title> Document</ title>
</ head>
< body>
< div id = " app" > </ div>
< script src = " ./vue.js" > </ script>
< script id = " mytemplate" type = " x-template" >
< section>
< h1> { { greeting} } < / h1>
< h1> { { greeting} } < / h1>
< / section>
</ script>
< script>
const app = new Vue ( {
el: '#app' ,
template: '#mytemplate' ,
data: {
greeting: 'Hello Vuejs'
}
} ) ;
</ script>
</ body>
</ html>
Use template render option to specify mount
<!DOCTYPE html>
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< meta name = " viewport" content = " width=device-width, initial-scale=1.0" >
< meta http-equiv = " X-UA-Compatible" content = " ie=edge" >
< title> Document</ title>
</ head>
< body>
< div id = " app" > </ div>
< script src = " ./vue.js" > </ script>
< script>
const app = new Vue ( {
el: '#app' ,
render: function ( createElement) {
return createElement ( 'h1' , this . greeting)
} ,
data: {
greeting: 'Hello Vuejs'
}
} ) ;
</ script>
</ body>
</ html>