需求:

将价值上加上元单位符号(全局filter)

<template>
<div>
衣服价格:{{productPrice|formatTime}} </div>
</template>
<script>
import Vue from 'vue'
Vue.filter('formatTime', function (value) {
return '¥'+value
})
export default {
name: 'side-bar-placeholder',
data () {
return {
productPrice:100
}
}
}
</script>
<style lang="less" scoped>
</style>

将价值上加上美元单位符号(全局filter)

<template>
<div>
衣服价格:{{productPrice|formatTime}}
</div>
</template>
<script> import Vue from 'vue'
export default {
name: 'side-bar-placeholder',
data () {
return {
productPrice:100
}
}, filters:{
formatTime:function (value){
return '$'+value
}
}
}
</script>
<style lang="less" scoped>
</style>



vue中全局filter和局部filter怎么用?的更多相关文章

  1. vue中全局组件与局部组件的注册,以及动态绑定props值

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 黑马vue---28、vue中全局过滤器的基本使用

    黑马vue---28.vue中全局过滤器的基本使用 一.总结 一句话总结: vue中的过滤器可以传递参数(根据参数来过滤),也可以用管道符拼接多个过滤器:例如<p>{{ msg | msg ...

  3. python中全局global和局部nonlocal命名空间

    python中全局global和局部nonlocal命名空间 局部名称空间对全局名称空间的变量可以引用,但是无法改变. count = 1 def func1(): count = 2 print(c ...

  4. vue 中全局filter过滤器的配置及使用

    在项目中使用到的经常用到过滤器,比如时间,数据截取等过滤器,如果在每个.vue中都可以复制同一个过滤器,这可以达到目的,但是遇到方法有bug时就需要诸葛修改进入不同的页面修改,这样既费时又费力,优先可 ...

  5. vue中全局引入bootstrap.css

    1.首先在官网上下载bootstrap的压缩包(必须是官网上下载的) 将压缩包解压后引入在项目文件夹下面.如下图所示: 2.在main.js中引入 import './assets/bootstrap ...

  6. Vue中全局过滤器期与局部过滤器期的使用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. vue(3)—— vue的全局组件、局部组件

    组件 vue有局部组件和全局组件,这个组件后期用的会比较多,也是非常重要的 局部组件 template与components属性结合使用挂载 其中 Vmain.Vheader.Vleft.Vconte ...

  8. vue 组件 全局注册和局部注册

    全局注册,注册的组件需要在初始化根实例之前注册了组件: 局部注册,通过使用组件实例选项注册,可以使组件仅在另一个组件或者实例的作用域中可用: 全局组件 js Vue.component('tab-ti ...

  9. 第二章 Vue快速入门-- 24 过滤器-Vue中全局过滤器的基本使用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

随机推荐

  1. pythdon day13:网络编程socket

    目录 day 13 learning python 49. 网络基础 49.1 IP地址 49.2 协议 50. socket编程(套接字编程) 50.1 socket编程简介 50.2 创建sock ...

  2. Protobuf的上手使用

    这里不赘述Json和Protobuf的比较和区别,只谈谈简单的使用 1.在Client-Server交互的过程中,都是以二进制数据传输,所以Json和Protobuf在使用的过程中,都存在序列化和反序 ...

  3. ssh修改端口

    安装防火墙 sudo yum -y install firewald sudo systemctl start firewald.service sudo firewall-cmd --list-al ...

  4. vue-element-admin 前端框架 使用感触

    感触: 不搜不知道,一搜吓一跳!经常百度很重要. 美国有gitgub:https://github.com/search?q=vue-element-admin 中国有码云:https://gitee ...

  5. DRF 有无外键操作实例

    models.py from django.db import models # Create your models here. class Category(models.Model): &quo ...

  6. IntelliJ Idea 依赖包下载成功,代码里无法import问题解决方法

    今天clone一个github上的基于maven的项目IntelliJ Idea 依赖包下载成功,代码里无法import.解决方法:删掉原来的.iml,刷新. 如果不行,可尝试:File->In ...

  7. mac中git flow使用

    初始化 git flow init   最后就一路回车选择默认的就ok了 常用命令以及分支:分支介绍:1.master.只有一个,并且不会在master上进行代码的操作.2.develop.只有一个, ...

  8. mysql学习之基础篇05

    mysql中的统计函数: 1. 查询商品价格中最高的价格: select max(shop_price) from goods; 2. 查询商品价格中最低的价格: select min(shop_pr ...

  9. The Essential Burp Suite

    OK   we have download teh burp suite .let's begin start the tool 1.if  we  want to use the total mem ...

  10. Linux 绑定 ttyUSBn 串口方法。

    Linux 绑定 ttyUSBn 串口方法. 在linux下, 使用usb转串口, 经常会碰到一个问题: 如果有多个串口, 以不同顺序插入的时候, /dev/ttyUSB0 /dev/ttyUSB1的 ...