vant-fork
Version:
Lightweight Mobile UI Components built on Vue
63 lines (59 loc) • 1.32 kB
JavaScript
import create from '../utils/create';
export default create({
render: function render() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c('i', {
staticClass: "van-hairline",
class: [_vm.b(), _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
}
});
},
name: 'key',
props: {
text: [String, Number],
type: {
type: Array,
default: function _default() {
return [];
}
}
},
data: function data() {
return {
active: false
};
},
computed: {
className: function className() {
var _this = this;
var types = this.type.slice(0);
this.active && types.push('active');
return types.map(function (type) {
return _this.b([type]);
});
}
},
methods: {
onFocus: function onFocus() {
this.active = true;
this.$emit('press', this.text);
},
onBlur: function onBlur() {
this.active = false;
}
}
});