vant
Version:
A Vue.js 2.0 Mobile UI at YouZan
48 lines (41 loc) • 1.17 kB
JavaScript
;
exports.__esModule = true;
exports.default = {
render: function render() {
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('i', { staticClass: "van-hairline van-key", class: _vm.className, domProps: { "textContent": _vm._s(_vm.text) }, on: { "touchstart": function touchstart($event) {
$event.stopPropagation();$event.preventDefault();return _vm.onFocus($event);
}, "touchmove": _vm.onBlur, "touchend": _vm.onBlur, "touchcancel": _vm.onBlur } });
},
props: {
text: [String, Number],
type: {
type: Array,
default: function _default() {
return [];
}
}
},
data: function data() {
return {
active: false
};
},
computed: {
className: function className() {
var types = this.type.slice(0);
this.active && types.push('active');
return types.map(function (type) {
return "van-key--" + type;
});
}
},
methods: {
onFocus: function onFocus() {
this.active = true;
this.$emit('press', this.text);
},
onBlur: function onBlur() {
this.active = false;
}
}
};