Learning journey of vue3 + typescript: Lenovo wallpaper library


Blog original addresswww.yunmobai.cn/blog/14

Project demonstration

Website Demo:bizhi.yunmobai.cn/

Website source code:gitee.com/baymaxsjj/by-vue-wallpap…

Website back end: the back-end interface of this project comes from Lenovo computer manager, software store and wallpaper. Recommended downloadLenovo computer manager, this project is only for personal learning.
Complete functions: Home rotation, classification, my wallpaper, wallpaper display, scroll loading, full screen display, add my favorite.
Completion progress: 95%. Basic realization and official basic functions.
Comparative display: the first line of the project, the second line from the official
This project is used to learn the knowledge of vue3 and typescript

Learning journey of vue3 + typescript: Lenovo wallpaper library Learning journey of vue3 + typescript: Lenovo wallpaper library Learning journey of vue3 + typescript: Lenovo wallpaper library
Learning journey of vue3 + typescript: Lenovo wallpaper library Learning journey of vue3 + typescript: Lenovo wallpaper library Learning journey of vue3 + typescript: Lenovo wallpaper library

Project introduction

Vue:3.0.0-0,Swiper: 6.3.1,TypeScript”: 3.9.3,VueX、VueRouter:4.0.0-0。
This project is to learn about vue3 and typescript, using vuex to manage data, and partly using typescript. The main reason is that I’m not familiar with this yet, and it’s very difficult to get in touch with it. To define the data type or report an error, I only use its syntax in vuex


Swiper is a very good plug-in for scrolling graphs, which have their own styles. This is also the first time that I have come into contact with Vue. Vue is now available in 3.0, and swiper6 also provides Vue components. Therefore, this project uses the swiper component method to write the home page carousel diagram. Refer toswiper/vue
Swiper / Vue provides two components, swipershiperslide
Basic use


      :pagination="{ clickable: true }"
      <swiper-slide v-for="item of list" :key="item.id">
        <router-link :to="'/class/'+item.targetContent">
          <img :src="item.imgUrl" width="644"/>

Parameter introduction:
Refer toSwiper

//Set the number of slides that the slider container can display at the same time
//Center display
//Cycle display
//To use slidesperview: 'auto' in loop mode, you also need to use this parameter to set the number of loops to be used (generally, the number of loops is greater than the number of visible slides by 2).
//Auto play
//Forward and backward button
//Pager navigation
:pagination="{ clickable: true }"
//Callback function, which is executed when swiper's progress is changed, sets the switching animation
//Callback function, executed whenever swiper starts transition animation


    //Traverse all slides carousel
         for (let i = 0; i < swiper.slides.length; i++) {
         //Get to carousel
        var slide = swiper.slides.eq(i);
        var slideProgress = swiper.slides[i].progress;
                let modify = 1;
                if (Math.abs(slideProgress) > 1) {
                    modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
                let translate = slideProgress * modify * 260 + 'px';
                let scale = 1 - Math.abs(slideProgress) / 5;
                let zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
                slide.transform('translateX(' + translate + ') scale(' + scale + ')');
                slide.css('zIndex', zIndex);
                slide.css('opacity', 1);
                if (Math.abs(slideProgress) > 2) {
                    slide.css('opacity', 0);
        setTransition(swiper,transition) {
            for (var i = 0; i < swiper.slides.length; i++) {
                var slide = swiper.slides.eq(i)

Rolling load

//The actual height of the document (including the height of invisible content)
        let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight
        //The height of the visible content of the document
        let clientHeight = window.innerHeight || Math.min(document.documentElement.clientHeight, document.body.clientHeight)
        //The distance from the top of the document's content, which is hidden when scrolling vertically, to the visible content in its viewport (the top of what is actually visible)
        let scrollTop = document.documentElement.scrollTop || document.body.scrollTop

        //Determine whether the vertical scroll bar scrolls to the bottom: scrollheight - scrolltop = = = clientheight
            if (scrollHeight - scrollTop <= clientHeight+150&&this.loading) {
              //// get data
              // console.log(this.list.skip)
              let url=this.url.replace('skip=0','skip='+(parseInt(this.list.skip)+parseInt(this.list.limit)))
                // store.commit('setLove',index)



In fact, this bug is very strange, that is, there is no problem with the development. After compiling, some functions of the rotation chart are lost. The main problem is that the forward and backward disappear. What’s wrong? Even the style is different. I’m convinced. I hope there’s a big God to point out
Learning journey of vue3 + typescript: Lenovo wallpaper library
Learning journey of vue3 + typescript: Lenovo wallpaper library

This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint

Recommended Today

The actor model is so excellent under distributed high concurrency

Write at the beginning In general, there are two strategies for communicating in concurrent threads: shared data and messaging. One of the biggest problems of concurrent programming with shared data is data condition competition. It’s a headache to deal with all kinds of locks. Most of the traditional popular language concurrency is based on shared […]