欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue中@click如何綁定多個(gè)事件

 更新時(shí)間:2023年11月14日 09:02:51   作者:HaanLen  
這篇文章主要介紹了vue中@click如何綁定多個(gè)事件問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

vue @click綁定多個(gè)事件

<div @click="show();scrollLyric()" class="showImg">
  methods: {
    show () {
      this.$store.commit('show')
    },
    scrollLyric () {
      setTimeout(() => {
        let lis = document.querySelectorAll('li')
        console.log(lis)
      }, 2000)
    }

vue @click 綁定點(diǎn)擊事件 方法傳遞參數(shù) typescript(通用)

話不多說(shuō)還是直接上圖 簡(jiǎn)單明了


<template>
  <div id="header">
    <img src="../../assets/logo.jpeg" />
    <div v-for="(item,i) in navList" v-bind:key="i" :to="item.path" @click.stop="show(item)">{{item.text}}</div>
    <div class="user_msg">
      <img src="../../assets/logo.jpeg" />
      <span>劉十</span>
    </div>
    <!-- <span @click="show(shiyan)" >搜索</span> -->
  </div>
</template>
<style lang='less'>
#header {
  background: RGBA(54, 55, 66, 1);
  color: #fff;
  height: 60px;
  box-sizing: border-box;
  line-height: 60px;
  padding: 0px 60px;
  display: flex;
  align-items: center;
  > img {
    height: 80%;
  }
  justify-content: space-between;
  .user_msg {
    display: flex;
    align-items: center;
    height: 100%;
    > span {
      margin-left: 30px;
    }
    img {
      height: 40px;
      width: 40px;
      border-radius: 20px;
    }
  }
}
</style>
<script lang='ts'>
import Vue from "vue";
interface NavItem{
    path:String,
    text:String,
}
//設(shè)置類(lèi)型
export default Vue.extend({
  name: "Nav",
  data() {
    return {
      navList: [
        {
          path: "/",
          text: "首頁(yè)"
        },
        {
          path: "/code",
          text: "編程"
        },
        {
          path: "/life",
          text: "生活"
        },
        {
          path: "/about",
          text: "關(guān)于"
        }
      ],
      shiyan:'898989'
    };
  },
  methods: {
    show(e:NavItem) {
      console.log(e.path)
    }
  }
});
</script>

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論