Table of Contents
Structure:
Home Web Front-end JS Tutorial JS imitation of Jinri Toutiao mobile terminal homepage interface

JS imitation of Jinri Toutiao mobile terminal homepage interface

Mar 23, 2018 pm 03:41 PM
javascript Home page interface

This time I will bring you JS to imitate the homepage interface of Toutiao mobile terminal. What are the precautions for imitating the homepage interface of Toutiao mobile terminal using JS. Here is a practical case, let’s take a look at it together.

Preface

I have been working on vue for a while. I have always wanted to use vue to write a mobile terminal. In addition, I am not very busy at the end of the year, so I started working on it a few days ago. So far today, I can barely read it

Because I am purely writing front-end pages, I use mock.js for data. In order to simulate real requests, you can directly generate the API yourself in Easy Mock
You can also directly log in to the Easy Mock account of my project Password:

Account: vue-toutiao
Password: 123456

If you want to modify the interface, please copy One copy is being modified

If you want to develop the backend interface yourself. You can read my blog Vue + Node + Mongodb Develop a complete blog process

Technology stack:

vue + webpack + vuex + axios

Structure:

  • build: webpack configuration

  • config: project configuration parameters

  • src

  • assets: Static resource files, storing pictures

  • components: Commonly used components. For example, pop-up windows, etc. . .

  • directive: Common instruction encapsulation

  • router: routing table

  • store: state management vuex

  • styles: style file

  • utils: common tool class package

  • views: view page

  • static: Static file: store favicon.ico, etc.

  • This project uses DllPlugin for packaging, so remember it when starting the project , first execute the script command once to generate the configuration

Effect demonstration:

Several common knowledge points

1. Lazy loading of routes

{
  path: '/development',
  name: 'development',
  component: (resolve) => {
    require(['../views/development.vue'], resolve)
  }
}
Copy after login

or

const _import_ = file => () => import('views/' + file + '.vue')
{
  path: '/development',
  name: 'development',
  component: _import_('development')
}
Copy after login

2. Login interception

Determine whether login is required through the beforeEach hook function of the route

// 如:系统设置需要登陆
{ 
  path: '/system', 
  name: '系统设置', 
  meta: { 
    login: true
  },
  component: _import_('System/index')
}
router.beforeEach((to, from, next) => {
  if (to.meta.login) { //判断前往的界面是否需要登陆
    if (store.state.user.user.name) { // 是否已经登陆
      next()
    }else{
      Vue.prototype.$alert('请先登录!')
        .then( () => {
          store.state.user.isLogin = true
        })
    }
  }else{
    if (to.meta.page) store.state.app.pageLoading = true
    next() 
  }
  
})
Copy after login

3. Animation switching

Determine what kind of switching animation it does by detecting the animate attribute set on the Router

Router.prototype.animate = 0
// 获取每个路由meta上面的slide 来判断它做什么动画
{ 
  path: '/system', 
  name: '系统设置', 
  meta: { 
    slide: 1 
  },
  component: _import_('System/index')
}
watch: {
  $route (to, from) {
    /*
    0: 不做动画
    1: 左切换
    2: 右切换
    3: 上切换
    4: 下切换
    ...
     */
    let animate = this.$router.animate || to.meta.slide
    if (!animate) {
      this.animate = '' 
    }else{
      this.animate = animate === 1 ? 'slide-left' :
        animate === 2 ? 'slide-right' :
        animate === 3 ? 'slide-top' :
        animate === 4 ? 'slide-bottom' : ''
    }
    this.$router.animate = 0
  }
}
Copy after login

4. Video playback

Because the video controls cannot be hidden on IOS, we can hide the video and achieve the effect of playing the video by drawing canvas

I believe you have mastered it after reading the case in this article Method, for more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Implement click-to-load loading in five-level areas

vue builds an automatic website building project

How to use echarts in Vue.JS

The above is the detailed content of JS imitation of Jinri Toutiao mobile terminal homepage interface. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

How to display the display window on the Douyin homepage How to display the display window on the Douyin homepage Mar 30, 2024 pm 08:36 PM

How to display the display window on the Douyin homepage? In the Douyin short video APP, you can add a display window to the homepage. Most users don’t know how to display the display window. Next, the editor brings users a graphic tutorial on how to display the display window on the Douyin homepage. , interested users come and take a look! Tutorial on how to use Douyin: How to display the showcase on Douyin homepage 1. First open the Douyin short video APP and enter the My Area, click on the three horizontal lines in the upper right corner and select [Creator Center]; 2. Then on the Creator Service Center page, select [ All categories] function; 3. Then find the [Product Showcase] service in the function list; 4. Then jump to the page shown in the picture below, click [Become a goods delivery expert]; 5. Finally, become a goods delivery expert interface, click [Application for Delivery Permission] at the bottom to display

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to Revert Google Chrome Home Page to Google Search How to Revert Google Chrome Home Page to Google Search Jan 30, 2024 pm 03:42 PM

How to change the Google Chrome homepage back to Google? Many friends like to use Google Chrome. Its exclusive navigation page is very easy to use, very concise, and has no ads or pop-up content. However, this homepage is often tampered with into other types of homepages. , many users don’t know how to change back to Google’s own homepage at this time. So, how to change back to Google’s homepage? Below, the editor will show you how to change the Google Chrome homepage back to Google. Method to change the Google Chrome homepage back to Google 1. Open Google Chrome and click the menu button in the upper right corner. 2. Click the "Settings" option. 3. Select the "Default Browser" option in the settings page. 4. Set Google Chrome as the default browser!

How to change Google Chrome homepage back to Google search engine How to change Google Chrome homepage back to Google search engine Mar 28, 2024 am 08:36 AM

How to change Google Chrome homepage back to Google search engine? Google Chrome is officially built by Google. This browser comes with Google search and Google translation functions. The default homepage of the Google Chrome we downloaded and installed is Google search. However, Google search cannot be used in China, so many friends Change the default search on the homepage to another search engine, so how to change the search engine on the homepage back? This article brings you the operation process of changing the Google Chrome homepage back to Google search. Friends in need should not miss it. Operation process of changing Google Chrome homepage back to Google Search 1. Open Google Chrome and click the menu button in the upper right corner (as shown in the picture). 2. Click the "Settings" option (as shown in the picture). 3

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

How to solve the problem of the browser homepage being modified How to solve the problem of the browser homepage being modified Jan 15, 2024 pm 04:03 PM

In the process of surfing the Internet, we often encounter situations where the homepage has been tampered with. The reason for this is mostly due to the emergence of a large number of advertising-profit navigation websites on the Internet. In order to seize traffic, they use "forcible" tampering techniques. So what should I do if the homepage is tampered with? Below, the editor will bring you pictures and text of how the browser homepage has been tampered with. We often encounter the problem of some software tampering with the homepage. After the homepage we set is tampered with, how should we reset the homepage? It can be said that every friend will encounter such troubles, and it is really a headache. So what should you do if your browser homepage has been tampered with? Next, the editor will explain to you how to deal with the tampering of the browser homepage. What to do if the browser homepage has been tampered with? Open the IE browser and find the upper right corner..

See all articles