1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <script>
- export default {
- render(createElement) {
- const vnodes = this.$slots.default;
- if (vnodes && vnodes.length) {
- for (let i = 0; i < vnodes.length; i++) {
- let vnode = vnodes[i];
- if (!vnode.data) {
- vnode.data = Object.create(null)
- }
- if (!vnode.data.on) {
- vnode.data.on = Object.create(null)
- }
- vnode.data.on.click = this._change;
- }
- }
- return createElement('div', {//如果需要左右滑动用scroller,不需要的话用div就行,添加个属性需要时将scroller添加 children
- style: {
- height:'100px',
- width:'750px',
- flexDirection:'row',
- borderBottomWidth: "1px",
- borderColor: "#F0F0F0",
- borderBottomStyle: "solid"
- }
- }, [
- createElement('scroller', {
- attrs: {
- scrollDirection:'horizontal',
- showScrollbar:'false'
- },
- style: {
- height:'100px',
- width:'750px',
- flexDirection:'row'
- }
- }, this.$slots.default)
- ])
- },
- methods:{
- _change(e){
- let ret = {
- index:e.index
- }
- if(e.type === 'click'){
- let target = e.target;
- ret.index = target.parentNode.children.findIndex(node=>node===target)
- }
- this.$emit('_tabBarClick', ret)
- }
- }
- }
- </script>
|