[Front-end study notes 3 - buttons not selected, global variables, tables not displayed, view variable values]

Front-end study notes three, coverage

If the button is not selected, it may be covered by other components. Use developer tools to select components, and you can add z-index to the style or use position to change relative positioning to absolute positioning.

 .back {
    
    
    z-index: 99999999;
    position: absolute;
    right: 40px;
    top: 95px;
  }

The label is not displayed in the el-option filter box, but the value is displayed, and some column filter boxes have labels and values
There is a problem with the filter box display

To write global variables, you can first write the global variables that need to be saved in the index.js file in the store folder

import Vue from 'vue'
import Vuex from 'vuex'


Vue.use(Vuex)

const  store =new Vuex.Store(
    {
    
    
        state:{
    
    
            name:"",
            index:0,
            schoolOption:[],
            studentId:'',
            classId:'',
            className:'',
            schoolId:'',
            teacherOP:[],
            adminCourseRowData:{
    
    },
            questionDetail:{
    
    },
            isComplete:false,
            tabName:'first',
        }
    }
)
export default store

Write store in the program main file main.js

import store from './store'
Vue.component('downloadExcel', JsonExcel)
new Vue({
    
    
    router,
    store,
    render: function (h) {
    
    
        return h(App)
    }
}).$mount('#app')

Save global variables when writing a refresh in App.vue

    // 在页面加载时读取sessionStorage里的状态信息
    if (sessionStorage.getItem('store')) {
    
    
      this.$store.replaceState(
          Object.assign(
              {
    
    },
              this.$store.state,
              JSON.parse(sessionStorage.getItem('store'))
          )
      )
    }
    window.addEventListener('beforeunload', () => {
    
    
      sessionStorage.setItem('store', JSON.stringify(this.$store.state))
    })
  }
}
</script>

Finally, remember to store variables in the login page or some starting page

this.$store.state.schoolId = this.ruleForm.schoolId;

usage of this.

In @click, there is no need to add this in front of the variable.

el-table form does not display

Pay attention to the elements in el-pagination. For example, if the total is not written correctly, it will not be displayed.
So when copying and modifying, you can use search and replace to avoid omissions.

view variable value

In the browser console, this.variable will be undefined directly.
The debugger must be stopped to view variable values ​​on the console.

Guess you like

Origin blog.csdn.net/weixin_47227105/article/details/128536135