Skip to content

Commit

Permalink
评论自动聚焦
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Jun 21, 2017
1 parent 92bdb32 commit 2b581a3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
30 changes: 20 additions & 10 deletions src/frames/find/friendcircle/friendcircle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<!-- 评论 -->
<section class="criticism" v-if="criticismstate">
<div class="criticism_con">
<textarea name="" id="" cols="30" rows="10" v-model="textareaVlue" @input="inputCriticism"></textarea>
<textarea name="" id="" cols="30" rows="10" ref="textinput" v-model="textareaVlue" @input="inputCriticism" @keyup.enter="enterThing"></textarea>
<span :class="{notempty:changeinput}" @click="commentSend">发送</span>
</div>
</section>
Expand Down Expand Up @@ -173,6 +173,9 @@
...mapActions([
"getUserInfo",
]),
enterThing(){
this.commentSend()
},
exportInput(){
this.afterclcik=false;
},
Expand Down Expand Up @@ -226,25 +229,32 @@
}
},
criticismThing(item){//评论
this.itemlist={};
this.itemlist=item;
this.criticismstate=true;
this.$nextTick(()=>{
this.$refs.textinput.focus();
})
this.commentHide(item);
},
inputCriticism(){//文本框是否为空
this.textareaVlue ? this.changeinput=true : this.changeinput=false;
},
commentSend(){//评论点击发送
if(this.textareaVlue){
this.itemlist.comment.push({
wxid:this.userInfoData.id,
petname:this.userInfoData.name,
commentext:this.textareaVlue
})
if(this.changeinput){
if(this.textareaVlue){
this.itemlist.comment.push({
wxid:this.userInfoData.id,
petname:this.userInfoData.name,
commentext:this.textareaVlue
})
}
this.criticismstate=false;
this.textareaVlue='';
this.changeinput=false;
}
this.criticismstate=false;
this.textareaVlue='';
this.changeinput=false;
}
}
}
Expand Down
24 changes: 14 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,36 @@ import './config/rem'
import FastClick from 'fastclick'

if ('addEventListener' in document) {
document.addEventListener('DOMContentLoaded', function() {
FastClick.attach(document.body);
}, false);
document.addEventListener('DOMContentLoaded', function() {
FastClick.attach(document.body);
}, false);
}

Vue.use(VueRouter)

const router = new VueRouter({
routes,
mode:'history', //路由模式
mode: 'history', //路由模式
strict: process.env.NODE_ENV !== 'production',
scrollBehavior (to, from, savedPosition) {
if(savedPosition){
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return {x:0,y:to.meta.savedPosition || 0}
return {
x: 0,
y: to.meta.savedPosition || 0
}
}
}
})
router.beforeEach((to, from, next) => {
if(from.meta.keepAlive){
if (from.meta.keepAlive) {
from.meta.savedPosition = document.body.scrollTop;
}
next()
next()
})

new Vue({
router,
store,
}).$mount("#weixin")
}).$mount("#weixin")

0 comments on commit 2b581a3

Please sign in to comment.