欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue實(shí)現(xiàn)商品詳情頁的評(píng)價(jià)列表功能

 更新時(shí)間:2019年09月04日 15:33:48   作者:前端大彬哥  
這篇文章主要介紹了Vue實(shí)現(xiàn)商品詳情頁的評(píng)價(jià)列表功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

本篇我們來實(shí)現(xiàn)商品詳情頁的評(píng)價(jià)列表。

 

必要的數(shù)據(jù)

這里咱們舉一個(gè)數(shù)據(jù)的例子,明明白白地了解這些數(shù)據(jù)是如何綁定到模板中的。

數(shù)據(jù)來自于Foods父組件,當(dāng)我們選中商品,跳轉(zhuǎn)到商品詳情頁,那么就需要依賴父組件中的商品數(shù)據(jù),在商品詳情頁面展示評(píng)論,當(dāng)然也可能沒有如下“rating”數(shù)據(jù)。那我們在后面的模板中,就不展示對(duì)應(yīng)的html結(jié)構(gòu)。

{
            "id": 96985579,
            "name": "麥辣雞翅2塊",
            "min_price": 11,
            "praise_num": 22,
            "praise_content": "贊22",
            "tread_num": 0,
            "praise_num_new": 22,
            "unit": "例",
            "description": "",
            "picture": "http://p0.meituan.net/xianfu/38bbfa3f955cbce3330f1cb6818d0ce6216794.png.webp",
            "month_saled": 948,
            "month_saled_content": "月售948",
            "status": 3,
            "status_description": "非可售時(shí)間",
            "product_label_picture": "http://p1.meituan.net/aichequan/04789347d755465713550540942265d36475.png",
            "rating": {
              "comment_count": 4,
              "title": "外賣評(píng)價(jià)",
              "snd_title": "4條評(píng)論",
              "praise_friends": "",
              "like_ratio_desc": "好評(píng)度",
              "like_ratio": "100%",
              "filter_type": 1,
              "comment_list": [
                {
                  "user_icon": "https://img.meituan.net/avatar/71ef89fa000e783d5b8d86c2767a9d28195580.jpg",
                  "user_name": "ejX309524666",
                  "comment_time": "2017.08.31",
                  "comment_unix_time": 1504161290,
                  "comment_content": "#奶油堅(jiān)果醬中套餐#不好吃。還是奧爾良,麥辣雞腿那些最經(jīng)典的漢堡好吃。薯?xiàng)l軟得不能再軟了。我備注了可樂換芬達(dá)也沒有換。#麥辣雞翅2塊#就還好,里面的肉挺嫩的,很入味。"
                }, {
                  "user_icon": "https://img.meituan.net/avatar/6571c42526237b0118f437418e989d1187445.jpg",
                  "user_name": "EAG789830055",
                  "comment_time": "2017.08.18",
                  "comment_unix_time": 1503030166,
                  "comment_content": "#麥辣雞翅2塊#送錯(cuò)"
                }
              ]
            }
          }

Food組件添加商品評(píng)價(jià)結(jié)構(gòu)

好,現(xiàn)在讓我們將評(píng)價(jià)結(jié)構(gòu)搭出來,并且綁定對(duì)應(yīng)的數(shù)據(jù)。

<templete>
  <transtition name="food-detail">
    <div class="food" v-show="showFlag" ref="foodView">
      <div class="food-wrapper">
        <div class="food-content"></div>
         <!-- 商品評(píng)價(jià)列表結(jié)構(gòu),數(shù)據(jù)的綁定渲染 -->
        <div class="rating-wrapper">
           <div class="rating-title">
            <div class="like-ratio" v-if="food.rating">
             <span class="title">{{food.rating.title}}</span>
             <span class="ratio">
              (
              {{food.rating.like_ratio_desc}}
              <i>{{food.rating.like_ratio}}</i>
              )
             </span>
            </div>
            <div class="snd-title" v-if="food.rating">
             <span class="text">{{food.rating.snd_title}}</span>
             <span class="icon icon-keyboard_arrow_right"></span>
            </div>
           </div>
           <ul class="rating-content" v-if="food.rating">
            <li v-for="comment in food.rating.comment_list" class="comment-item">
             <div class="comment-header">
              <img :src="comment.user_icon" v-if="comment.user_icon">
              <img src="./anonymity.png" v-if="!comment.user_icon">
             </div>
             <div class="comment-main">
              <div class="user">{{comment.user_name}}</div>
              <div class="time">{{comment.comment_time}}</div>
              <div class="content">{{comment.comment_content}}</div>
             </div>
            </li>
           </ul>
        </div>
      </div>
    </div>
  </transition>
</templete>

導(dǎo)入,注冊組件

<script>
  // 導(dǎo)入BScroll
  import BScroll from "better-scroll";
  // 導(dǎo)入Cartcontrol
  import Cartcontrol from "components/Cartcontrol/Cartcontrol";
  // 導(dǎo)入Vue
  import Vue from "vue";
  
  export default {
   data() {
    return {
     showFlag: false
    };
   },
    //接收來自Goods父組件中選中的food;
   props: {
    food: {
     type: Object
    }
   },
   methods: {
    //這里是上篇我們實(shí)現(xiàn)商品詳情頁的方法
   },
   components: {
    Cartcontrol,
    BScroll
   }
};
</script>

到這里我們就完成了商品詳情頁面的評(píng)論列表,下篇我們來實(shí)現(xiàn)商品評(píng)價(jià)欄目。

總結(jié)

以上所述是小編給大家介紹的Vue實(shí)現(xiàn)商品詳情頁的評(píng)價(jià)列表功能,希望對(duì)大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

  • Vue.js?前端路由和異步組件介紹

    Vue.js?前端路由和異步組件介紹

    這篇文章主要介紹了Vue.js?前端路由和異步組件介紹,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-09-09
  • vue 實(shí)現(xiàn)復(fù)制內(nèi)容到粘貼板clipboard的方法

    vue 實(shí)現(xiàn)復(fù)制內(nèi)容到粘貼板clipboard的方法

    下面小編就為大家分享一篇vue 實(shí)現(xiàn)復(fù)制內(nèi)容到粘貼板clipboard的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • vue3中的hooks總結(jié)

    vue3中的hooks總結(jié)

    這篇文章主要介紹了vue3中的hooks總結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-05-05
  • vue之郵箱、密碼、手機(jī)號(hào)碼等輸入驗(yàn)證規(guī)則說明

    vue之郵箱、密碼、手機(jī)號(hào)碼等輸入驗(yàn)證規(guī)則說明

    這篇文章主要介紹了vue之郵箱、密碼、手機(jī)號(hào)碼等輸入驗(yàn)證規(guī)則說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • 簡單的Vue SSR的示例代碼

    簡單的Vue SSR的示例代碼

    本篇文章主要介紹了簡單的 Vue SSR的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-01-01
  • vue 使用 v-model 雙向綁定父子組件的值遇見的問題及解決方案

    vue 使用 v-model 雙向綁定父子組件的值遇見的問題及解決方案

    這篇文章主要介紹了vue 使用 v-model 雙向綁定父子組件的值遇見的問題及解決方案,幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下
    2021-03-03
  • 詳解vue-class遷移vite的一次踩坑記錄

    詳解vue-class遷移vite的一次踩坑記錄

    本文主要介紹了vue-class遷移vite的一次踩坑記錄,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • 詳解Vue2中組件間通信的解決全方案

    詳解Vue2中組件間通信的解決全方案

    Vue中組件這個(gè)特性讓不少前端er非常喜歡,我自己也是其中之一,它讓前端的組件式開發(fā)更加合理和簡單。下面這篇文章主要給大家介紹了關(guān)于Vue2中組件間通信的解決全方案,文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面來一起看看吧。
    2017-07-07
  • vue中監(jiān)聽scroll事件失效的問題及解決

    vue中監(jiān)聽scroll事件失效的問題及解決

    這篇文章主要介紹了vue中監(jiān)聽scroll事件失效的問題及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • 對(duì)類Vue的MVVM前端庫的實(shí)現(xiàn)代碼

    對(duì)類Vue的MVVM前端庫的實(shí)現(xiàn)代碼

    這篇文章主要介紹了對(duì)類Vue的MVVM前端庫的實(shí)現(xiàn)代碼,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-09-09

最新評(píng)論