成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

vue指令v-html使用過濾器filters功能實(shí)例

問題

在通遼等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站制作、成都網(wǎng)站制作 網(wǎng)站設(shè)計(jì)制作定制網(wǎng)站建設(shè),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),營銷型網(wǎng)站建設(shè),外貿(mào)網(wǎng)站制作,通遼網(wǎng)站建設(shè)費(fèi)用合理。

2.0 filters only work in mustache tags and v-bind.

Vue2.0 不再支持在 v-html 中使用過濾器,比如在 1.0 中是這樣使用的:

{{{ option.title | highlight }}}

然而,現(xiàn)在不能使用了,Vue2.0 的過濾器現(xiàn)在只能應(yīng)用在 {{ }} 和 v-bind 中。

然而,嫌麻煩,還想使用怎么辦?

解決方法

  • 使用全局方法
  • 使用 computed 屬性
  • 使用 $options.filters

使用全局方法

put your highlight into methods, and v-html="highlight(option.title)"

可以在 Vue 上定義全局方法:

Vue.prototype.highlight= function (sTitle) {
 // to do
};

然后所有組件上都可以直接用這個(gè)方法了:

v-html="highlight(option.title)"

使用 computed 屬性

  • What if I have a filter that outputs HTML? Do I have to use a computed property or is there a better way?
  • Computed properties are the best way. You get automatic caching.

當(dāng)然,可以使用計(jì)算屬性 computed,返回原生 html 給 v-html 即可。

使用 $options.filters

You can use $options.filters

v-html="$options.filters.highlight(option.title)".

這個(gè)方式在文檔中并沒有說明,但是這也是可靠的方法。

You can safely rely on that: $options are the options passed to the Vue constructor when creating a vm (so any component or new Vue). From that point on is just javascript

以上就是本次介紹的關(guān)于vue指令v-html使用的全部知識點(diǎn),感謝大家的閱讀和對創(chuàng)新互聯(lián)的支持。

本文標(biāo)題:vue指令v-html使用過濾器filters功能實(shí)例
URL分享:http://jinyejixie.com/article36/jjijsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司外貿(mào)網(wǎng)站建設(shè)、ChatGPT、App開發(fā)、App設(shè)計(jì)小程序開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)
乌拉特前旗| 济阳县| 琼结县| 江孜县| 巍山| 介休市| 集贤县| 明光市| 台东县| 贡觉县| 淄博市| 曲周县| 民权县| 宜兰市| 济源市| 喀喇沁旗| 青川县| 玉环县| 南华县| 乌兰浩特市| 平昌县| 若羌县| 台东市| 博野县| 松原市| 延吉市| 来凤县| 莒南县| 玉林市| 和政县| 长顺县| 咸阳市| 海丰县| 利津县| 闵行区| 广灵县| 英超| 开江县| 内乡县| 维西| 合阳县|