vue-vjs
v0.0.7
Published
Js extend for Vue and Vue template
Downloads
2
Readme
vue-vjs
Js extend for Vue and Vue template
Install
npm install vue-vjs
Usage
import { default as Vjs, incase, returnDeep } from 'vue-vjs'
Vue.use(Vjs)
// use Vue.use(Vjs) to use it in Vue template
// or use incase, returnDeep directly..
returnDeep (fix property of 'undefined')
const test = {
a: {
b: {
c: {
d: 'test'
}
}
}
}
returnDeep(test)(['a', 'b', 'c', 'd'])
// 'test'
returnDeep(test)(['a', 'b', 'ffff', 'd'])
returnDeep(test)(['a', 'b', 'c', 'ffff'])
returnDeep(undefined)(['a', 'b', 'c', 'd'])
returnDeep(test)([undefined, 'b', 'c', 'd'])
// undefined
incase (switch)
incase(5)([
// case 1
x => x === 1,
'is 1',
// case 2
() => 2,
() => 'is 2',
// case 3
3,
() => 'is 3'
() => 4,
'is 4'
], 'default value')
// ], () => 'default value')
in Vue template
import Vjs from 'vue-vjs'
Vue.use(Vjs)
{{
vjs.incase(1)([
1,
'is 1'
])
}}