Vue3.0过滤器

时间:2021-02-24 11:45:30   收藏:0   阅读:435

Vue3.0过滤器

全局属性

// main.js
const app = createApp(App)

app.config.globalProperties.$filters = {
  currencyUSD(value) {
    return ‘$‘ + value
  }
}

在页面中使用

<template>
  <h1>Bank Account Balance</h1>
  <p>{{ $filters.currencyUSD(accountBalance) }}</p>
</template>

优化

//main.js
// 过滤器
import filters from "@/filters";
app.config.globalProperties.$filters = filters;
export default {
  currencyUSD(value) {
	return ‘$‘ + value
  }
}

原文:https://www.cnblogs.com/1748sb/p/14439645.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!