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)文章
關(guān)于VanCascader默認(rèn)值(地址code轉(zhuǎn)換)
這篇文章主要介紹了關(guān)于VanCascader默認(rèn)值(地址code轉(zhuǎn)換),具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-07-07vue項(xiàng)目中使用bpmn為節(jié)點(diǎn)添加顏色的方法
這篇文章主要介紹了vue項(xiàng)目中使用bpmn為節(jié)點(diǎn)添加顏色的方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04Vue elementUI 自定義表單模板組件功能實(shí)現(xiàn)
在項(xiàng)目開(kāi)發(fā)中,我們會(huì)遇到這種需求,在管理后臺(tái)添加自定義表單,在指定的頁(yè)面使用定義好的表單,這篇文章主要介紹了Vue elementUI 自定義表單模板組件,需要的朋友可以參考下2022-12-12vue-cli3項(xiàng)目在IE瀏覽器打開(kāi)兼容問(wèn)題及解決
這篇文章主要介紹了vue-cli3項(xiàng)目在IE瀏覽器打開(kāi)兼容問(wèn)題及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08基于vue監(jiān)聽(tīng)滾動(dòng)事件實(shí)現(xiàn)錨點(diǎn)鏈接平滑滾動(dòng)的方法
本篇文章主要介紹了基于vue監(jiān)聽(tīng)滾動(dòng)事件實(shí)現(xiàn)錨點(diǎn)鏈接平滑滾動(dòng)的方法,非常具有實(shí)用價(jià)值,有興趣的可以了解一下2018-01-01淺談實(shí)現(xiàn)vue2.0響應(yīng)式的基本思路
這篇文章主要介紹了淺談實(shí)現(xiàn)vue2.0響應(yīng)式的基本思路,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-02-02