防止浏览器窗口太小,设置最小宽度 | 您所在的位置:网站首页 › 怎么设置浏览器界面大小 › 防止浏览器窗口太小,设置最小宽度 |
nuxt服务端渲染 vue检测图片加载失败onerror时,自定义指令处理
兰-->叶落初的爱恋: import { DirectiveBinding } from 'nuxt/dist/app/compat/capi' export default defineNuxtPlugin(() => { const nuxtApp = useNuxtApp() const defaultImg = new URL('../assets/img/school.png', importa.url).href nuxtApp.vueApp.directive('deImg', (el: HTMLImageElement, dir: DirectiveBinding) => { // 图片加载失败 isExistImg(el.src).catch(() => { el.src = defaultImg }) }) }) export const isExistImg = (url: string) => { let isExistImg: boolean = false return new Promise((resolve, reject) => { const img = document.createElement('img') img.src = url img.onload = function () { isExistImg = true resolve(isExistImg) } img.onerror = function () { isExistImg = false reject(isExistImg) } }) } 56个民族下拉选择框木与青: 为什么我的不显示? hbuilderX 加入到文件右键菜单波波的笔记本: 试了,没起作用,, nuxt.js配置反向代理跨域nuxtjs/axios和@nuxtjs/proxy艾小逗: 不会的 js随机生成颜色getRandomColor代码波博博波: 可以的兄弟,typeit官网的demo彩色函数没了,你这个正好名字都一样,谢谢 |
CopyRight 2018-2019 实验室设备网 版权所有 |