vue模板中写html,vue中template的三种写法示例

编程知识 更新时间:2023-04-04 23:22:06

第一种(字符串模板写法):

直接写在vue构造器里,这种写法比较直观,适用于html代码不多的场景,但是如果模板里html代码太多,不便于维护,不建议这么写.

/*

Example kicking off the UI. Obviously, adapt this to your specific needs.

Assumes you have a

*/

new Vue({

el: '#q-app',

data: function () {

return {

version: Quasar.version

}

},

template: `

Running Quasar v{{ version }} `

// ...etc

})

第二种:

直接写在template标签里,这种写法跟写html很像。

Running Quasar v{{ version }}

/*

Example kicking off the UI. Obviously, adapt this to your specific needs.

Assumes you have a

*/

new Vue({

el: '#q-app',

data: function () {

return {

version: Quasar.version

}

},

template: '#template1'

// ...etc

})

第三种:

写在script标签里,这种写法官方推荐,vue官方推荐script中type属性加上"x-template",即:

Running Quasar v{{ version }}

/*

Example kicking off the UI. Obviously, adapt this to your specific needs.

Assumes you have a

*/

new Vue({

el: '#q-app',

data: function () {

return {

version: Quasar.version

}

},

template: '#template1'

// ...etc

})

以上就是vue中template的三种写法示例的详细内容,更多关于vue template的资料请关注脚本之家其它相关文章!

更多推荐

vue模板中写html,vue中template的三种写法示例

本文发布于:2023-04-04 23:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/3d8d540c4dd3dbf179a6971da5e7ca79.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:三种   写法   示例   模板   vue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 43710文章数
  • 14阅读数
  • 0评论数