vue2中事件

<template>

<div class="topic">


 


  <a href="/" @click.native="get()">btn</a>

     <li><a @click="fn()">全部</a></li>

     <button @click="post()">btn</button>

</div>

</template>


<script>


export default {

    data() {

        return {

        }

    },

    methods: {

        get() {

            console.log("ggggg")

        },

        fn() {

            alert('触发');

        },

        post() {

            alert('没反应。。。。。');

        }

    }

}

</script>


<style scoped>

</style>

https://img4.mukewang.com/5c99952f0001f0cd06710173.jpg

项目截图 初次使用vue 希望各位大佬指点一二

https://img4.mukewang.com/5c9995320001e5ea03240686.jpg

https://img2.mukewang.com/5c9995330001d33108000635.jpg

互换的青春
浏览 427回答 3
3回答

千巷猫影

这样是可以的,你刷新或者重新编译下<template>&nbsp; <div class="user">&nbsp; &nbsp; <div class="user-name" @click="fn()">&nbsp; &nbsp; &nbsp; <div></div>&nbsp; &nbsp; &nbsp; 最多五个字&nbsp; &nbsp; </div>&nbsp; </div></template><script>&nbsp; export default {&nbsp; &nbsp; name: "barTop",&nbsp; &nbsp; data() {&nbsp; &nbsp; &nbsp; return {&nbsp; &nbsp; &nbsp; &nbsp; isShow: false&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; },&nbsp; &nbsp; mounted() {&nbsp; &nbsp; },&nbsp; &nbsp; created() {&nbsp; &nbsp; },&nbsp; &nbsp; methods: {&nbsp; &nbsp; &nbsp; fn(){&nbsp; &nbsp; &nbsp; &nbsp; console.log('aaa')&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; }</script><style scoped>&nbsp; @import url('./barTop.less');</style>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript