@skyrpex/now
Vue mixin that generates a reactive time variable
Last updated 2 years ago by skyrpex .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @skyrpex/now 
SYNC missed versions from official npm registry.

Now

CircleCI AppVeyor Build status TravisCI Build status

Works with:

Vue 2 Vue 1

This mixin will create a computed property with a Moment.js instance. The computed property will be updated at a given interval to stay up to date.

Installation

npm install @skyrpex/now

Usage

Minimal setup

<template>
  <div>
    <!-- Print the current time, and update each second. -->
    <p>{{ now }}</p>
  </div>
</template>

<script>
import now from '@skyrpex/now';

export default {
  mixins: [
    // Will inject a 'now' computed property
    now({ /* options... */ }),
  ],
};
</script>

Another use case

<template>
  <div>
    <!-- You can use any Moment.js method -->
    <p>{{ now.from(createdAt) }}</p>
  </div>
</template>

<script>
import moment from 'moment';
import now from '@skyrpex/now';

export default {
  mixins: [now()],
  data: () => ({
    createdAt: moment([2007, 0, 28]),
  }),
};
</script>

Options

import now from '@skyrpex/now';

now({
  name: 'now', // Name of the computed property
  interval: 1000, // Update interval
});

Current Tags

  • 0.0.1-2                                ...           beta (2 years ago)
  • 1.1.0                                ...           latest (2 years ago)

5 Versions

  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.1-2                                ...           2 years ago
  • 0.0.1-1                                ...           2 years ago
  • 0.0.1-0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 15
Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2018 © taobao.org |