最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue中template的三種寫(xiě)法示例

 更新時(shí)間:2020年10月21日 08:32:43   作者:默默的點(diǎn)滴  
這篇文章主要介紹了vue中template的三種寫(xiě)法示例,幫助大家更好的理解和學(xué)習(xí)vue,感興趣的朋友可以了解下

第一種(字符串模板寫(xiě)法):

直接寫(xiě)在vue構(gòu)造器里,這種寫(xiě)法比較直觀(guān),適用于html代碼不多的場(chǎng)景,但是如果模板里html代碼太多,不便于維護(hù),不建議這么寫(xiě).

<!DOCTYPE html>
<html>
 <!--
  WARNING! Make sure that you match all Quasar related
  tags to the same version! (Below it's "@1.7.4")
 -->

 <head>
   <!--
   <link  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css">
   -->
   <link  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css">
 </head>

 <body>
  <div id="q-app">

  </div>

  <!-- Add the following at the end of your body tag -->
  <!--
  <script src="https://cdn.jsdelivr.net/npm/vue@^2.0.0/dist/vue.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/quasar@1.7.4/dist/quasar.umd.min.js"></script>
  -->
  <script src="https://www.mobibrw.com/wp-content/uploads/2020/06/vue@2.0.0.js"></script>
  <script src="https://www.mobibrw.com/wp-content/uploads/2020/06/quasar.umd@1.7.4.js"></script>
  
  <script>
   /*
    Example kicking off the UI. Obviously, adapt this to your specific needs.
    Assumes you have a <div id="q-app"></div> in your <body> above
    */
   new Vue({
    el: '#q-app',
    data: function () {
     return {
      version: Quasar.version
     }
    },
    template: `<div class="q-ma-md"> Running Quasar v{{ version }}</div>`
    // ...etc
   })
  </script>
 </body>
</html>

第二種:

直接寫(xiě)在template標(biāo)簽里,這種寫(xiě)法跟寫(xiě)html很像。

<!DOCTYPE html>
<html>
 <!--
  WARNING! Make sure that you match all Quasar related
  tags to the same version! (Below it's "@1.7.4")
 -->

 <head>
   <!--
   <link  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css">
   -->
   <link  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css">
 </head>

 <body>
  <div id="q-app">
    <template id='template1'>
     <div class="q-ma-md">
      Running Quasar v{{ version }}
     </div>
    </template>
  </div>

  <!-- Add the following at the end of your body tag -->
  <!--
  <script src="https://cdn.jsdelivr.net/npm/vue@^2.0.0/dist/vue.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/quasar@1.7.4/dist/quasar.umd.min.js"></script>
  -->
  <script src="https://www.mobibrw.com/wp-content/uploads/2020/06/vue@2.0.0.js"></script>
  <script src="https://www.mobibrw.com/wp-content/uploads/2020/06/quasar.umd@1.7.4.js"></script>
  
  <script>
   /*
    Example kicking off the UI. Obviously, adapt this to your specific needs.
    Assumes you have a <div id="q-app"></div> in your <body> above
    */
   new Vue({
    el: '#q-app',
    data: function () {
     return {
      version: Quasar.version
     }
    },
    template: '#template1'
    // ...etc
   })
  </script>
 </body>
</html>

第三種:

寫(xiě)在script標(biāo)簽里,這種寫(xiě)法官方推薦,vue官方推薦script中type屬性加上"x-template",即:

<!DOCTYPE html>
<html>
 <!--
  WARNING! Make sure that you match all Quasar related
  tags to the same version! (Below it's "@1.7.4")
 -->

 <head>
   <!--
   <link  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css">
   -->
   <link  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css">
 </head>

 <body>
  <div id="q-app"></div>
	
	<script type="x-template" id="template1">
  	<div class="q-ma-md">
   	 Running Quasar v{{ version }}
  	</div>
  </script>

  <!-- Add the following at the end of your body tag -->
  <!--
  <script src="https://cdn.jsdelivr.net/npm/vue@^2.0.0/dist/vue.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/quasar@1.7.4/dist/quasar.umd.min.js"></script>
  -->
  <script src="https://www.mobibrw.com/wp-content/uploads/2020/06/vue@2.0.0.js"></script>
  <script src="https://www.mobibrw.com/wp-content/uploads/2020/06/quasar.umd@1.7.4.js"></script>
  
  <script>
   /*
    Example kicking off the UI. Obviously, adapt this to your specific needs.
    Assumes you have a <div id="q-app"></div> in your <body> above
    */
   new Vue({
    el: '#q-app',
    data: function () {
     return {
      version: Quasar.version
     }
    },
    template: '#template1'
    // ...etc
   })
  </script>
 </body>
</html>

以上就是vue中template的三種寫(xiě)法示例的詳細(xì)內(nèi)容,更多關(guān)于vue template的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 如何使用 vue + d3 畫(huà)一棵樹(shù)

    如何使用 vue + d3 畫(huà)一棵樹(shù)

    這篇文章主要介紹了如何使用 vue + d3 畫(huà)一棵樹(shù),本文通過(guò)文字說(shuō)明加代碼分析的形式給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-12-12
  • 詳細(xì)分析vue響應(yīng)式原理

    詳細(xì)分析vue響應(yīng)式原理

    這篇文章主要介紹了vue響應(yīng)式原理的的相關(guān)資料,文中講解非常細(xì)致,代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-06-06
  • vue實(shí)現(xiàn)分頁(yè)組件

    vue實(shí)現(xiàn)分頁(yè)組件

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)分頁(yè)組件的具體代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-12-12
  • Vue消息提示this.$message方法使用解讀

    Vue消息提示this.$message方法使用解讀

    這篇文章主要介紹了Vue消息提示this.$message方法使用,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,
    2023-09-09
  • Vue中computed和watch的區(qū)別

    Vue中computed和watch的區(qū)別

    在vue項(xiàng)目中我們常常需要用到computed和watch,那么我們究竟在什么場(chǎng)景下使用computed和watch呢?他們之間又有什么區(qū)別呢?本將給大家詳細(xì)的介紹一下,需要的朋友可以參考下
    2023-05-05
  • Vite創(chuàng)建項(xiàng)目的實(shí)現(xiàn)步驟

    Vite創(chuàng)建項(xiàng)目的實(shí)現(xiàn)步驟

    隨著 Vite2 的發(fā)布并日趨穩(wěn)定,現(xiàn)在越來(lái)越多的項(xiàng)目開(kāi)始嘗試使用它。本文我們就介紹了Vite創(chuàng)建項(xiàng)目的實(shí)現(xiàn)步驟,感興趣的可以了解一下
    2021-07-07
  • 詳解Vue 中 extend 、component 、mixins 、extends 的區(qū)別

    詳解Vue 中 extend 、component 、mixins 、extends 的區(qū)別

    這篇文章主要介紹了Vue 中 extend 、component 、mixins 、extends 的區(qū)別,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2017-12-12
  • vue項(xiàng)目如何引入json數(shù)據(jù)

    vue項(xiàng)目如何引入json數(shù)據(jù)

    這篇文章主要介紹了vue項(xiàng)目如何引入json數(shù)據(jù),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • 簡(jiǎn)單了解vue 插值表達(dá)式Mustache

    簡(jiǎn)單了解vue 插值表達(dá)式Mustache

    這篇文章主要介紹了vue 插值表達(dá)式Mustache的相關(guān)資料,文中講解非常細(xì)致,代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-07-07
  • 值得收藏的vuejs安裝教程

    值得收藏的vuejs安裝教程

    這篇文章主要為大家分享了一篇值得收藏的vuejs安裝教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11

最新評(píng)論

司法| 临泉县| 闸北区| 丰城市| 贺州市| 化州市| 阳西县| 霍城县| 晋江市| 招远市| 江源县| 保德县| 柞水县| 都江堰市| 靖州| 鲁甸县| 灵宝市| 仙居县| 三江| 宝兴县| 繁昌县| 鄂托克旗| 临朐县| 藁城市| 佛冈县| 博兴县| 鄂伦春自治旗| 来宾市| 望奎县| 济阳县| 台中市| 汝城县| 牡丹江市| 类乌齐县| 苏州市| 南充市| 涞水县| 自治县| 阿拉善右旗| 怀宁县| 康马县|