Skip to content
Array object operation under Vue
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
LICENSE
README-zh.md
README.md
index.js
package-lock.json
package.json
utils.js

README.md

Vue-Array

Node Version Build Status Coverage Status Npm Downlaod

NPM

中文文档

Use this package to manipulate the array. Vue can monitor the changes in the array

If you can, you can use the Vue.set method.

install

# Install with npm
$ npm install vue-array --save

# Install with yarn
$ yarn add vue-array

Usage

Vue Plug-in

demo: https://codesandbox.io/s/jppo9w6yyw

Ordinary

let vueArray = require('vue-array').$array

let arr = [1, 2, 3, -0 , 0]
vueArray(arr).remove([2, 1]).remove(0)
console.log(arr) // => [3, -0]

vueArray(arr).replace([4, 5, 6]).replace(['a', 'b', 'c'])
console.log(arr) // => ['a', 'b', 'c']

Instance

let arrInstance = Array
require('vue-array').injection(arrInstance)

let arr = [1, 2, 3]
[].$array(arr).remove([3,1])
console.log(arr) // => [2]

[].$array(arr).replace([4, 5, 6])
console.log(arr) // => [4, 5, 6]

API

remove

Support numbers, strings, Boolean, Null Undefined NaN, Object, Array, ±0

If it is an object, an array, support recursive judgment

let arr = [
  "abc", 123, -0, 0, false, true, null, undefined, NaN,
  [1, 2, 3],
  [4, 5, 6],
  {a: 1},
  {b: 1},
  [{a: 2}],
  [{b: 2}],
  {a: [7,8, {b: 3}]}
]

vueArray(arr).remove([
  null, true, 0, "abc", NaN,
  [1, 2, 3],
  [{b: 2}],
  {a: 1},
  {a: [7,8, {b: 3}]}
])

console.log(arr)
/**
[
  123, -0, fasle, undefined,
  [4, 5, 6],
  {b: 1},
  [{a: 2}],
]
**/

replace

let arr = [1, 2, 3, 4, 'a', NaN, {a: 1}, [2,1]]
vueArray(arr).replace(['a', 'b', 'c'])

console.log(arr) // => ['a', 'b', 'c']

Running tests

Install dev dependencies:

$ npm test

Contributing

Commits Contributor
7 Black-Hole

Author

Black-Hole

You can’t perform that action at this time.