Skip to content

页面增加滚动事件,button增加click事件 #718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"url": "https://github.com/ydcss/vue-ydui.git"
},
"scripts": {
"dev": "webpack-dev-server --content-base example/ --port 4321 --inline --hot --host 0.0.0.0 --config build/webpack.dev.conf.js",
"dev": "webpack-dev-server --content-base example/ --port 4321 --inline --hot --host localhost --config build/webpack.dev.conf.js",
"build:rem:components": "webpack --config build/webpack.dist.components.rem.conf.js",
"build:px:components": "webpack --config build/webpack.dist.components.px.conf.js",
"build:prod": "webpack --config build/webpack.dist.prod.conf.js",
Expand Down Expand Up @@ -57,6 +57,7 @@
"style-loader": "^0.13.1",
"vue": "^2.5.2",
"vue-loader": "^10.0.2",
"vue-resource": "^1.0.3",
"vue-router": "^2.1.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^1.14.0",
Expand Down
7 changes: 6 additions & 1 deletion src/components/badge/src/badge.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<span class="yd-badge" :class="typesClass"
:style="{backgroundColor: bgcolor, color: color, transform: 'scale('+scale+')'}">
:style="{backgroundColor: bgcolor, color: color, transform: 'scale('+scale+')'}" @click='click'>
<slot></slot>
</span>
</template>
Expand Down Expand Up @@ -50,6 +50,11 @@
}
return (this.type ? 'yd-badge-' + this.type : '') + (this.shape === 'square' ? ' yd-badge-radius' : '');
}
},
methods:{
click(){
this.$emit('click', event);
}
}
}
</script>
Expand Down
7 changes: 6 additions & 1 deletion src/components/button/src/button.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<button :disabled="disabled || loading" :class="classes" :style="{backgroundColor: bgcolor, color: color}" :type="actionType">
<button :disabled="disabled || loading" :class="classes" :style="{backgroundColor: bgcolor, color: color}" :type="actionType" @click="handleClickLink">
<span class="yd-btn-loading" v-if="loading">
<span class="yd-btn-rolling" :class="rollingClasses" :style="{marginRight: loadingTxt ? '8px' : '0'}"><i></i></span>
<template v-if="size === 'large'">{{loadingTxt}}</template>
Expand Down Expand Up @@ -103,6 +103,11 @@

return s + t + r;
}
},
methods: {
handleClickLink (event) {
this.$emit('click', event);
}
}
}
</script>
Expand Down
13 changes: 9 additions & 4 deletions src/components/cell/src/cell-item.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<label class="yd-cell-item" v-if="type == 'label' || type == 'checkbox' || type == 'radio'">
<label class="yd-cell-item" v-if="type == 'label' || type == 'checkbox' || type == 'radio'" @click="handleClickLink">
<span class="yd-cell-left" v-if="checkLeft">
<span class="yd-cell-icon" v-if="$slots.icon"><slot name="icon"></slot></span>
<slot name="left"></slot>
Expand All @@ -10,7 +10,7 @@
<i v-if="type == 'radio'" class="yd-cell-radio-icon"></i>
</label>
</label>
<router-link class="yd-cell-item" :to="href" v-else-if="type == 'link'">
<router-link class="yd-cell-item" :to="href" v-else-if="type == 'link'" @click="handleClickLink">
<div class="yd-cell-left" v-if="checkLeft">
<span class="yd-cell-icon" v-if="$slots.icon"><slot name="icon"></slot></span>
<slot name="left"></slot>
Expand All @@ -19,7 +19,7 @@
<slot name="right"></slot>
</div>
</router-link>
<a class="yd-cell-item" :href="href" v-else-if="type == 'a'">
<a class="yd-cell-item" :href="href" v-else-if="type == 'a'" @click="handleClickLink">
<div class="yd-cell-left" v-if="checkLeft">
<span class="yd-cell-icon" v-if="$slots.icon"><slot name="icon"></slot></span>
<slot name="left"></slot>
Expand All @@ -28,7 +28,7 @@
<slot name="right"></slot>
</div>
</a>
<div class="yd-cell-item" v-else>
<div class="yd-cell-item" v-else @click="handleClickLink">
<div class="yd-cell-left" v-if="checkLeft">
<span class="yd-cell-icon" v-if="$slots.icon"><slot name="icon"></slot></span>
<slot name="left"></slot>
Expand Down Expand Up @@ -64,6 +64,11 @@
classes() {
return this.arrow ? 'yd-cell-arrow' : '';
}
},
methods: {
handleClickLink (event) {
this.$emit('click', event);
}
}
}
</script>
Expand Down
9 changes: 7 additions & 2 deletions src/components/grids/src/grids-item.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<router-link class="yd-grids-item" :to="link || ''" :style="styles" :class="$parent.itemHeight != 0 ? 'yd-grids-item-center' : ''" v-if="type == 'link'">
<router-link class="yd-grids-item" :to="link || ''" :style="styles" :class="$parent.itemHeight != 0 ? 'yd-grids-item-center' : ''" v-if="type == 'link'" @click="handleClickLink">
<div class="yd-grids-icon" v-if="checkIcon">
<slot name="icon"></slot>
</div>
Expand All @@ -8,7 +8,7 @@
</div>
<slot name="else"></slot>
</router-link>
<a class="yd-grids-item" :href="link || ''" :style="styles" :class="$parent.itemHeight != 0 ? 'yd-grids-item-center' : ''" v-else>
<a class="yd-grids-item" :href="link || ''" :style="styles" :class="$parent.itemHeight != 0 ? 'yd-grids-item-center' : ''" v-else @click="handleClickLink">
<div class="yd-grids-icon" v-if="checkIcon">
<slot name="icon"></slot>
</div>
Expand Down Expand Up @@ -46,6 +46,11 @@
};
}
}
},
methods: {
handleClickLink (event) {
this.$emit('click', event);
}
}
};
</script>
Expand Down
20 changes: 18 additions & 2 deletions src/components/layout/src/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<slot name="top"></slot>

<section class="yd-scrollview" ref="scrollView" id="scrollView">
<section class="yd-scrollview" ref="scrollView" id="scrollView" @scroll="scroll">
<slot></slot>
</section>

Expand All @@ -23,14 +23,30 @@
<script type="text/babel">
export default {
name: 'yd-layout',
data(){
return {scrollTop:0};
},
props: {
link: String,
title: String,
showNavbar: {
type: Boolean,
default: true
},
onScroll:{
type:Function,
default:null
}
}
},
methods: {
scroll() {
this.scrollTop=event.target.scrollTop;
this.onScroll&&this.onScroll(event,this);
}
},
activated(){
this.$refs['scrollView'].scrollTop = this.scrollTop;
},
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/tab/src/tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
}

if (!this.value && this.value !== 0 && this.currentIndex !== key) {
if (!tabkey) {
if (typeof(tabkey)!='undefined') {
key = tabkey;
}
this.callback && this.callback(label, key);
Expand Down