SoFunction
Updated on 2025-03-04

Specific methods of using xe-utils function library for vue

This article introduces the specific method of vue using the xe-utils function library. I will share it with you, as follows:

After installation is completed, it will be automatically mounted in the vue instance: this.$utils (function library)

Supported mount function list: this.$browse (browser kernel judgment) this.$locat (used to read and write address bar parameters)

The function called via this.$utils in a vue instance points to the current vue instance by default.

CDN installation

Install using script, VXEUtils will be defined as a global variable

Please use , a smaller compressed version in the production environment, which can bring a faster speed experience.

cdnjs get the latest version

Click to browseSource code for all published npm packages.

<script src="/npm/[email protected]/dist/"></script>

unpkg Get the latest version

Click to browseSource code for all published npm packages

<script src="/[email protected]/dist/"></script>

AMD Installation

Installation example

// require configuration({
 paths: {
  // ...,
  'xe-utils': './dist/',
  'vxe-utils': './dist/'
 }
})

// ./ Installdefine(['Vue', 'xe-utils', 'vxe-utils'], function (Vue, XEUtils, VXEUtils) {
 (VXEUtils, XEUtils)
})

ES6 Module installation method

npm install xe-utils vxe-utils --save

Install globally through ()

import Vue from 'vue'
import XEUtils from 'xe-utils'
import VXEUtils from 'vxe-utils'

(VXEUtils, XEUtils)

// Calling method through vue instanceconst dateStr = this.$(new Date(), 'yyyy-MM-dd')
const date = this.$('11/20/2017 10:10:30', 'MM/dd/yyyy HH:mm:ss')

vue instance mounts custom properties

Example

import Vue from 'vue'
import XEUtils from 'xe-utils'
import VXEUtils from 'vxe-utils'
import customs from './customs'

(customs)
(VXEUtils, XEUtils, {mounts: ['locat', 'browse', 'cookie']})

this.$locat // this.$
this.$browse // this.$browse['-webkit'] true
this.$cookie // this.$cookie('name', 'value')

Mixed functions

document ./

export function custom1 () {
 ('Custom functions')
} 

Example ./

import Vue from 'vue'
import XEUtils from 'xe-utils'
import customs from './customs'

(customs)
(VXEUtils, XEUtils)

// Call custom extension functionXEUtils.custom1()

Example

&lt;template&gt;
 &lt;div&gt;
  &lt;ul&gt;
   &lt;li v-for="item in list" :key=""&gt;{{  }}or{{ $() }}&lt;/li&gt;
  &lt;/ul&gt;
 &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
 data () {
  return {
   list: []
  }
 },
 methods: {
  init () {
   this.$('services/user/list', {id: 123})
   .then(data =&gt; {
     = (item =&gt; {
      = this.$(, 'MM/dd/yyyy')
    })
   }).catch(data =&gt; {
     = []
   })
  }
 },
 created () {
  ()
 }
}
&lt;/script&gt;

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.