2024年最全Vue自定义指令(1),挑战华为社招

跳槽是每个人的职业生涯中都要经历的过程,不论你是搜索到的这篇文章还是无意中浏览到的这篇文章,希望你没有白白浪费停留在这里的时间,能给你接下来或者以后的笔试面试带来一些帮助。

也许是互联网未来10年中最好的一年。WINTER IS COMING。但是如果你不真正的自己去尝试尝试,你永远不知道市面上的行情如何。这次找工作下来,我自身感觉市场并没有那么可怕,也拿到了几个大厂的offer。在此进行一个总结,给自己,也希望能帮助到需要的同学。

面试准备

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

面试准备根据每个人掌握的知识不同,准备的时间也不一样。现在对于前端岗位,以前也许不是很重视算法这块,但是现在很多公司也都会考。建议大家平时有空的时候多刷刷leetcode。算法的准备时间比较长,是一个长期的过程。需要在掌握了大部分前端基础知识的情况下,再有针对性的去复习算法。面试的时候算法能做出来肯定加分,但做不出来也不会一票否决,面试官也会给你提供一些思路。

import Vue from ‘vue’
import router from ‘@/router’
import {btnPermissionCheck} from “@/network/common/common”;
Vue.directive(‘permission’, {
inserted: async function(el, binding){
el.style.display=‘none’;
const code = binding.value.code
let show = binding.value.show//有的按钮需根据state/status判断是否展示,当不传值时默认显示,不这样的话所有按钮都会显示两遍
if(show=== void 0)show=true

    const currentRight = router.currentRoute.meta;
    if(currentRight) {
        let res=await btnPermissionCheck({code:'99'+code,platformId:11,routeId:currentRight.routerId});
        if(show&&res.code===200&&res.data){
            el.style.display='inline-block';
        }
    }
}

})


使用方法



<span class=“table_font_Btn” @click=“handleRow(‘EDIT’,record)” v-permission=“{code:‘11080303’,show:record.status==0?true:false}”>编辑


输入数字



Vue.directive(‘integer’, {
bind (el, binding, vnode) {
var input = el.getElementsByTagName(‘input’)[0]
input.addEventListener(‘input’, function () {
var val = input.value
var regex = /1\d*$/
if (!regex.test(val)) {
input.value = val.replace(/[^\d]/g, ‘’)
vnode.context[binding.expression] = parseInt(input.value)
} else {
vnode.context[binding.expression] = parseInt(input.value)
}
})
}
})


省略 自定义指令



Vue.directive('ellipsis', {
  inserted (el) {
    toolTip(el)
  },
  componentUpdated (el) {
    toolTip(el)
  },
  unbind () {
    const kxmTooltipDom = document.getElementById('kxm-tooltip');
    kxmTooltipDom && document.body.removeChild(kxmTooltipDom);
  }
})

const toolTip = (el) => {
const curStyle = window.getComputedStyle(el, ‘’)
const textSpan = document.createElement(‘span’)
textSpan.style.fontSize = curStyle.fontSize
textSpan.style.fontWeight = curStyle.fontWeight
textSpan.style.fontFamily = curStyle.fontFamily
document.body.appendChild(textSpan)
textSpan.innerHTML = el.innerText
if (textSpan.offsetWidth > el.offsetWidth) {
el.style.overflow = ‘hidden’
el.style.textOverflow = ‘ellipsis’
el.style.whiteSpace = ‘nowrap’
el.onmouseenter = (e) => {
const kxmTooltipDom = document.createElement(‘div’)
kxmTooltipDom.style.cssText = display: inline-block; max-width: 400px; max-height: 400px; position: absolute; top: ${e.clientY + 5}px; left: ${e.clientX}px; padding: 10px; overflow: auto; font-size: 14px; color: #fff; background: rgba(0, 0 , 0, .6); border-radius: 5px; z-index: 19999
kxmTooltipDom.setAttribute(‘id’, ‘kxm-tooltip’)
document.body.appendChild(kxmTooltipDom)
document.getElementById(‘kxm-tooltip’).innerHTML = el.innerText
}
el.onmouseleave = () => {

紧跟潮流

大前端和全栈是以后前端的一个趋势,懂后端的前端,懂各端的前端更加具有竞争力,以后可以往这个方向靠拢。

这边整理了一个对标“阿里 50W”年薪企业高级前端工程师成长路线,由于图片太大仅展示一小部分

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】


  1. 1-9 ↩︎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值