[BootstrapVue] Sliding and monitoring Scrollspy to realize restaurant food display

1. Introduction

Renderings:

Description: Automatically updates a bootstrap navigation or list group component based on scroll position to indicate which link is currently active in the viewport.

Function: It can be used for the sidebar of the dish display page of the restaurant ordering, the sidebar of the blog system, etc., to achieve smooth vertical scrolling monitoring

Official website: Scrollspy | Directives | BootstrapVue (bootstrap-vue.org)

In this article, mainly on the basis of official documents, two ways of presenting data are provided,

  1. Put the data in data and load it in div

  1. Get the data passed from the backend, store it in the data, and then load it

2. Environment preparation

Need to install node.js in advance, I am using vue2, bootstrap-vue”version: 2.23.1,

  1. Install bootstrap-vue using npm or yarn

// choose one of two ways
npm install vue bootstrap bootstrap-vue
yarn add vue bootstrap bootstrap-vue
  1. Register BootstrapVue at the application entry, (usually app.js or main.js)

import Vue from 'vue'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'

// Import Bootstrap and BootstrapVue CSS files (order is important)
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

// Make BootstrapVue available throughout your project
Vue. use(BootstrapVue)
// Optionally install the BootstrapVue icon components plugin
Vue.use(IconsPlugin)
  1. Other things needed, such as axios required for front-end and back-end interaction, etc.

3.