所以这是我的代码。当我用鼠标按下按钮时它会重新加载页面,但是当我按下回车键时它不会刷新。任何想法怎么做?
<template lang="html">
<div class="chat-composer">
<input maxlength="180" type="text" placeholder="mesajınızı yazınız" v-model="messageText" @keyup.enter="sendMessage">i
<button class="btn btn-primary" @click="sendMessage" onClick="window.location.reload();>Gönder</button>
</div>
</template>
这里是我使用的代码。所以我不是专家..我需要帮助
<template lang="html">
<div class="chat-composer">
<input maxlength="180" type="text" placeholder="mesajınızı yazınız" v-model="messageText"
@keyup.enter="sendMessage">
<button class="btn btn-primary" @click="sendMessage" onClick="window.location.reload();"
>Gönder</button>
</div>
</template>
<script>
export default {
data() {
return {
messageText: ''
}
},
methods: {
sendMessage(){
this.$emit('messagesent',{
message: this.messageText,
user: {
name: $('.navbar-right .dropdown-toggle').text()
}
});
this.messageText = '';
},
},
}
</script>
答案 0 :(得分:1)
你正在使用Vue.js,如果是这样你可以做这样的事情
<button class="btn btn-primary" v-on:keyup.enter="window.location.reload()"
@click="sendMessage" onClick="window.location.reload();>Gönder</button>
查看关键修改器