vue.2.4.0.js_一个简单的Vue.js 2.0 MomentJS库

vue.2.4.0.js

Vue-Moment-lib (vue-moment-lib)

A Vue.js 2.0 MomentJS library

一个Vue.js 2.0 MomentJS库

Make momentjs available in your template and Vue instance. Since it just try to map raw js function, api is same asmomentjs.com. Making it easier to use in your Vue.js projects.

使Momentjs在模板和Vue实例中可用。 由于它只是尝试映射原始js函数,因此api与asmomentjs.com相同。 使其更易于在Vue.js项目中使用。

It added moment and duration as filters and component instance functions ($moment and $duration).

它添加了矩和持续时间作为过滤器和组件实例函数($ moment和$ duration)。

Generated using vue-cli-template-library.

使用vue-cli-template-library生成。

A Vue.js 2.0 MomentJS library

一个Vue.js 2.0 MomentJS库

Make momentjs available in your template and Vue instance. Since it just try to map raw js function, api is same as momentjs.com. Making it easier to use in your Vue.js projects.

使Momentjs在模板和Vue实例中可用。 由于它只是尝试映射原始js函数,因此api与momentjs.com相同。 使其更易于在Vue.js项目中使用。

It added moment and duration as filters and component instance functions ($moment and $duration).

它添加了矩和持续时间作为过滤器和组件实例函数($ moment和$ duration)。

Generated using vue-cli-template-library.

使用vue-cli-template-library生成

安装 (Installation)

npm install vue-moment-lib

vue-moment-lib can be used as a module in both CommonJS and ES modular environments.

vue-moment-lib可以在CommonJS和ES模块化环境中用作模块。

When in non-modular environment, vue-moment-lib will register all the components to vue by itself.

在非模块化环境中,vue-moment-lib将自己注册所有组件到vue。

ES6 (ES6)

//
// Register the whole module with vue
//
import VueMomentLib from 'vue-moment-lib';

// Install this library
Vue.use(VueMomentLib);

普通JS (CommonJS)

//
// Register the whole module with vue
//
var Vue = require('vue');
var VueMomentLib = require('vue-moment-lib');

// Install this library
Vue.use(VueMomentLib);

浏览器 (Browser)

<script src="path/to/vue/vue.min.js"></script>
<script src="path/to/moment/moment.min.js"></script>
<script src="path/to/vue-moment-lib/dist/vue-moment-lib.min.js"></script>
<!-- Filter and moment are registered globally -->

之后,您可以在模板中使用持续时间和矩过滤器,由于第一个参数通过管道传递,因此api略有不同: (After that, you can use the duration and moment filters in your templates, api is slightly different as the first argument is passed through pipe:)

<!-- first argument of moment filter is a parameter for parsing to UTC, it is set by default to false so it is optional when you use default parsing -->

<!-- Local format -->
<span>{{ Date.now() | moment().format("YYYY") }}</span>

<!-- isLocal + custom parsing + custom format -->
<span>{{ "11-14-2018" | moment(false, "MM-DD-YYYY").format("YYYY") }}</span>

<!-- isUTC + custom format -->
<span>{{ Date.now() | moment(true).format("YYYY") }}</span>

<!-- Duration is supported -->
<span>{{ 500 | duration("minutes").humanize() }}</span>

<!-- 1500 milliseconds -->
<span>{{ 1500 | duration("milliseconds").milliseconds() }}</span>

而且,在模板中使用$ duration和$ moment组件实例函数可以真正使用与momentjs相同的API: (And also, use the $duration and $moment component instance functions in your templates to really use the same apis as momentjs:)

<!-- Local format -->
<span>{{ $moment(Date.now()).format("YYYY") }}</span>

<!-- isLocal + custom parsing + custom format -->
<span>{{ $moment("11-14-2018", "MM-DD-YYYY").format("YYYY") }}</span>

<!-- isUTC + custom format -->
<span>{{ $moment.utc(Date.now()).format("YYYY") }}</span>

<!-- Duration is supported -->
<span>{{ $duration(500, "minutes").humanize() }}</span>

<!-- 1500 milliseconds -->
<span>{{ $duration(1500, "milliseconds").milliseconds() }}</span>

要么 (or)

// in your components
methods: {
  now () {
    return this.$moment(Date.now()).format()
  },
  humanize () {
    return this.$duration(500).humanize()
  }
}

// it is also registered as a global function in the Vue instance
// so you can do in vuex store or everywhere else to retrieve the same moment instance you initialized
import Vue from 'vue'
const thisYear = Vue.moment(Date.now()).format("YYYY")

自定义时刻实例 (Custom moment instances)

import yourMoment from 'moment'
import VueMomentLib from 'vue-moment-lib';

//
// customize your moment instance here (locales, config, etc)
//

// Install this library with custom moment instance
Vue.use(VueMomentLib, { moment: yourMoment });

翻译自: https://vuejsexamples.com/a-simple-vue-js-2-0-momentjs-library/

vue.2.4.0.js

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: vue.js devtools_5.3.3_chrome.cn.zip是一种用于谷歌浏览器的vue.js开发工具包,适用于开发vue.js前端应用程序。该工具包可以协助开发者对vue.js应用程序进行调试和监视。它包含了一些非常有用的功能,例如实时调试、状态管理、路由、组件、事件和动画工具等。 除了基本的功能外,vue.js devtools_5.3.3_chrome.cn.zip还提供了其他一些高级功能,例如缩放、搜索、过滤、追踪等。开发者可以使用这些功能来调试js代码、优化性能、测试响应时间等。 总体来说,vue.js devtools_5.3.3_chrome.cn.zip是一款非常实用的开发工具包,它可以协助开发者快速快速定位和解决vue.js应用程序中的问题,以便更好的提升应用程序的质量和用户体验。 ### 回答2: vue.js devtools_5.3.3_chrome.cn.zip是一个用于开发vue.js应用程序的Chrome浏览器插件,它提供了一系列工具和功能,帮助开发人员更好地调试和优化vue.js应用程序。 该插件允许你检查Vue组件的状态、属性、事件、计算属性和生命周期钩子,以及Vue实例的状态和组件层次结构。还可以追踪Vue活动,包括事件和网络请求,以及检查Vue.js开发者工具现有的应用程序状态。 该插件的另一个有用的功能是实时编辑和重载Vue组件,从而加快开发和测试过程。这个特性可以帮助开发人员实时查看他们所做的更改的结果,而无需手动刷新。 使用vue.js devtools_5.3.3_chrome.cn.zip将大大简化Vue.js应用程序开发和调试的过程,并帮助开发人员更加高效地工作。无论是在开发阶段还是在生产环境中,这个插件都是一个必备的工具。 ### 回答3: vue.js devtools_5.3.3_chrome.cn.zip是一款针对Vue.js开发的Chrome浏览器插件,可用于更方便地透视Vue.js应用程序并进行调试。使用此插件,用户可以轻松查看Vue组件树,进行状态和属性的检查和更改,并进行事件分析和调试。此外,vue.js devtools还具有性能分析功能,可以帮助开发者分析应用程序的性能数据,以及验证和优化应用程序的瓶颈。总之,vue.js devtools是一款实用而强大的工具,可以大大提高开发Vue.js应用程序的效率和质量。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值