vue v-text 如何使用 filter 方法
HTML:
<div id="vm"> <span v-text="$options.filters.dateFilter(item.create_time)"></span> </div>
JS:
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script> var vm = new Vue({ el: '#vm', data: { create_time: "2022-02-14T13:49:07" }, filters: { dateFilter: function (value) { if (!value) return ''; return value.replace('T', ' '); }, } });