In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the example analysis of lazy loading of lazyload pictures in Vue. The article is very detailed and has a certain reference value. Interested friends must finish reading it!
1. Install cnpm I vue-lazyload-S or npm I vue-lazyload-S2. Example
Import configuration and other operations such as src/main.js
Import Vue from 'vue'import App from'. / App'import router from'. / router'// [1] Import lazy load import VueLazyload from 'vue-lazyload'Vue.use (VueLazyload) / / [1] lazy load use (and the following sentence 2 choose 1) / / [1] lazy load use, and enter the global configuration There is no need to configure error pictures, etc. (2 choose 1) / / Vue.use (VueLazyload, {/ / preLoad: 1.3, / / load time / / error: 'dist/error.png', / / the picture incorrectly displays this picture / / loading:' dist/loading.gif' / / the loading process displays this figure / / attempt: 1 / / default number of loaded pages / /}) Vue.config.productionTip = false / * eslint-disable no-new * / new Vue ({el:'# app', router, template:', components: {App}})
Load src/components/lazy.vue using laziness
[1] define picture error display, etc. (introduce a picture, if it is in js. Must require come in)
[2] use lazy loading to write vmurlazywritten xxx'
Export default {name: "lazy", data () {return {/ / [1] defines the wrong display of pictures, etc. (introduce pictures, if in js. Must require in) imgObj: {preLoad: 1.3, / / load time src: "http://www.wwtliu.com/sxtstu/blueberrypai/indexImg/banner1.jpg",// real picture error: require (".. / assets/error.jpg "), / / if this picture is displayed incorrectly, loading: require (".. / assets/loadding.jpg ") / / the loading process displays this figure attempt: 1, / / default number of loaded pages}, imgUrl: "http://www.wwtliu.com/sxtstu/blueberrypai/indexImg/banner2.jpg" / / add only one entry That is, the real picture}}
Effect: the picture loaded when the address of the picture is wrong. The loading process displays a picture of the loading process.
The above is all the contents of the article "sample Analysis of lazy loading of lazyload pictures in Vue". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.