vue2.j 动态class、v-if 活学活用

本文展示了如何在Vue2.js中使用动态class和v-if指令来实现页面交互。通过点击不同的配置选项(服务配置、网络配置、端口配置),相应组件根据v-if条件显示和隐藏,同时应用不同class实现高亮状态。这种方式增强了用户体验并优化了代码结构。

<template>

  <div class="cfg-page-con poi">

    <div class="page-inline">

      <div class="page-bestinline">

        <div class="layout">

          <div class="page-upper">

            <div class="page" :class="{'active':isActive}" style="width:65px" @click="a">服务配置</div>

            <div class="page" :class="{'active':isActive1}" style="width:65px" @click="b">网络配置</div>

            <div class="page" :class="{'active':isActive2}" style="width:65px" @click="c">端口配置</div>

          </div>

          <div>

            <div v-if="show">

              <ServerCfg></ServerCfg>

            </div>

            <div v-if="show1">

              <NetCfg></NetCfg>

            </div>

            <div v-if="show2">

              <PortCfg></PortCfg>

            </div>

          </div>

        </div>

        <img src="@/assets/img/fire-saver.jpg" style="margin-top:90px" class="function-img" alt="">

        <!-- <el-collapse v-model="activeNames" @change="handleChange" accordion>

          <el-collapse-item class="serve"  title="服务配置" name="1">

            <ServerCfg></ServerCfg>

          </el-collapse-item>

          <el-collapse-item class="bottom" title="网络配置" name="2">

            <NetCfg></NetCfg>

          </el-collapse-item>

          <el-collapse-item title="端口配置" name="3">

            <PortCfg></PortCfg>

          </el-collapse-item>

        </el-collapse> -->

      </div>

    </div>

  </div>

</template>

<script>

import ServerCfg from './ServerCfg'

import NetCfg from './NetCfg'

import PortCfg from './PortCfg'

import PwdModify from './PwdModify'

import FireCfg from './FireCfg'

export default {

  name: 'index',

  components: {

    FireCfg,

    ServerCfg: ServerCfg,

    NetCfg: NetCfg,

    PortCfg: PortCfg,

    PwdModify: PwdModify

  },

  data() {

    return {

      activeNames: ['1'],

      fireVer: '消防配置 ',

      show: true,

      show1: false,

      show2: false,

      isActive: true,

      isActive1: false,

      isActive2: false

    }

  },

  methods: {

    handleChange(val) {

      console.log(val)

    },

    changedFire(val) {

      this.fireVer = val

    },

    a() {

      this.show = true

      this.show1 = false

      this.show2 = false

      this.isActive = true

      this.isActive1 = false

      this.isActive2 = false

    },

    b() {

      this.show = false

      this.show1 = true

      this.show2 = false

      this.isActive = false

      this.isActive1 = true

      this.isActive2 = false

    },

    c() {

      this.show = false

      this.show1 = false

      this.show2 = true

      this.isActive = false

      this.isActive1 = false

      this.isActive2 = true

    }

  }

}

</script>

<style scoped>

.cfg-page-con {


 

  overflow-x: hidden;

  overflow-y: auto;

}

::v-deep .el-collapse-item__header.is-active {

  border-bottom: 1px solid #ebeef5;

}

::v-deep .el-collapse-item__wrap {

  border: none;

}

.page-inline {

  background-color: #fff;

  border-radius: 15px;

  margin-top: 15px;

}

.page-bestinline {

  padding: 20px;

}

.bottom {

  margin-bottom: 10px;

}

.left-serve {

  font-size: 16px;

  color: black;

  margin-top: 20px;

}

.layout {

  display: flex;

  /* justify-content: center; */

}

.page-upper{

 cursor: pointer;

}

.page {

  padding: 3px;

  width: 10%;

  font-size: 16px;

  color: black;

  margin-top: 10px;

  background-color: #fff;

}

.active {

  color: rgba(0, 0, 0, 0.863);

  font-size: bold;

    border-bottom: 2px solid #4BA0FC;

}

.active:hover {

  color: #4BA0FC;

  font-size: bold;

    border-bottom: 2px solid #4BA0FC;

}

body{

  cursor: pointer;

}

.poi{

  cursor: pointer;

}

</style>

请分析下面控制台报错:tps://github.com/vuejs/vue-devtools axios-interceptors.js?55ef:62 Object request.js?b775:81 检查认证信息 axios-interceptors.js?55ef:62 Object axios-interceptors.js?55ef:62 Object TabsView.vue?2dce:375 routes Array(5) TabsView.vue?2dce:375 routes Array(12) TabsView.vue?2dce:375 routes Array(5) axios-interceptors.js?55ef:62 Object :8080/#/todo:1 Uncaught (in promise) Object request.js?b775:81 检查认证信息 SideMenu.vue?950f:63 obj Object axios-interceptors.js?55ef:62 Object axios-interceptors.js?55ef:62 Object request.js?b775:81 检查认证信息 axios-interceptors.js?55ef:62 Object vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "Yes" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "No" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "createVisible" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "loading" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "handleCreateOk" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "handleCreateCancel" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "loading" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "form" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "formLayout" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "StepForms" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: Cannot read property 'length' of undefined" found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'length' of undefined at Proxy.render (Autoreposition.vue?b778:1374) at VueComponent.Vue._render (vue.runtime.esm.js?2b0e:3548) at VueComponent.updateComponent (vue.runtime.esm.js?2b0e:4066) at Watcher.get (vue.runtime.esm.js?2b0e:4479) at new Watcher (vue.runtime.esm.js?2b0e:4468) at mountComponent (vue.runtime.esm.js?2b0e:4073) at VueComponent.Vue.$mount (vue.runtime.esm.js?2b0e:8415) at init (vue.runtime.esm.js?2b0e:3118) at merged (vue.runtime.esm.js?2b0e:3301) at createComponent (vue.runtime.esm.js?2b0e:5978) logError @ vue.runtime.esm.js?2b0e:1888 Autoreposition.vue?bbec:763 新建 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "Yes" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "No" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "createVisible" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "loading" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "handleCreateOk" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "handleCreateCancel" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "loading" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "form" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "formLayout" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "StepForms" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: Cannot read property 'length' of undefined" found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'length' of undefined at Proxy.render (Autoreposition.vue?b778:1374) at VueComponent.Vue._render (vue.runtime.esm.js?2b0e:3548) at VueComponent.updateComponent (vue.runtime.esm.js?2b0e:4066) at Watcher.get (vue.runtime.esm.js?2b0e:4479) at Watcher.run (vue.runtime.esm.js?2b0e:4554) at flushSchedulerQueue (vue.runtime.esm.js?2b0e:4310) at Array.eval (vue.runtime.esm.js?2b0e:1980) at flushCallbacks (vue.runtime.esm.js?2b0e:1906) logError @ vue.runtime.esm.js?2b0e:1888 axios-interceptors.js?55ef:62 Object axios-interceptors.js?55ef:62 Object :8080/api/surroundinga/erc/listPurposeCode/J2A:1 Failed to load resource: the server responded with a status of 404 (Not Found) :8080/api/surroundinga/erc/listEquipmentType/J2A:1 Failed to load resource: the server responded with a status of 404 (Not Found) 2axios-interceptors.js?55ef:103 onRejected :8080/api/surroundinga/erc/listChangeCode/J2A:1 Failed to load resource: the server responded with a status of 404 (Not Found) axios-interceptors.js?55ef:103 onRejected 3createError.js?2d83:16 Uncaught (in promise) Error: Request failed with status code 404 at createError (createError.js?2d83:16) at settle (settle.js?467f:17) at XMLHttpRequest.handleLoad (xhr.js?b50d:62) axios-interceptors.js?55ef:62 Object vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "Yes" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "No" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "createVisible" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "loading" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "handleCreateOk" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "handleCreateCancel" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "loading" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "form" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "formLayout" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "StepForms" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: Cannot read property 'length' of undefined" found in ---> <Process> at src/pages/mlcs/NewApplication/Mlcs/Autoreposition.vue <PageToggleTransition> at src/components/transition/PageToggleTransition.vue <Anonymous> <ALayoutContent> <Anonymous> <ALayout> <Anonymous> <ALayout> <AdminLayout> at src/layouts/AdminLayout.vue <TabsView> at src/layouts/tabs/TabsView.vue <ALocaleProvider> <LocaleReceiver> <AConfigProvider> <App> at src/App.vue <Root> warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'length' of undefined at Proxy.render (Autoreposition.vue?b778:1374) at VueComponent.Vue._render (vue.runtime.esm.js?2b0e:3548) at VueComponent.updateComponent (vue.runtime.esm.js?2b0e:4066) at Watcher.get (vue.runtime.esm.js?2b0e:4479) at Watcher.run (vue.runtime.esm.js?2b0e:4554) at flushSchedulerQueue (vue.runtime.esm.js?2b0e:4310) at Array.eval (vue.runtime.esm.js?2b0e:1980) at flushCallbacks (vue.runtime.esm.js?2b0e:1906)
最新发布
11-02
从你提供的控制台报错信息来看,前端页面存在多个 **Vue 渲染警告(Vue warn)** 和 **接口 404 错误**,这些是导致页面无法正常显示的主要原因。 --- ## 🔥 控制台报错分析与修复建议 --- ### 🧨 一、Vue 渲染警告(Property or method "xxx" is not defined) #### 🔍 报错示例: ``` [Vue warn]: Property or method "Yes" is not defined on the instance but referenced during render. [Vue warn]: Property or method "No" is not defined on the instance but referenced during render. [Vue warn]: Property or method "createVisible" is not defined... [Vue warn]: Property or method "StepForms" is not defined... ``` #### ✅ 原因: 这些警告说明你在模板中使用了未在 `data()` 或 `methods` 中定义的变量或方法,例如: ```vue <a-radio :value="Yes">Yes</a-radio> <a-radio :value="No">No</a-radio> ``` 你使用了 `Yes` 和 `No`,但它们没有在 `data()` 中定义。 #### ✅ 修复建议: ##### 1. 在 `data()` 中定义 `Yes` 和 `No`: ```js data() { return { Yes: 'Yes', No: 'No', createVisible: false, loading: false, form: {}, // 如果你用到了 form 对象 } } ``` ##### 2. 或者直接使用字符串: ```vue <a-radio value="Yes">Yes</a-radio> <a-radio value="No">No</a-radio> ``` ##### 3. 如果你使用了 `StepForms`: 确保 `searchData.StepForms` 被初始化为数组: ```js data() { return { searchData: { StepForms: [] } } } ``` --- ### 🧨 二、TypeError: Cannot read property 'length' of undefined #### 🔍 报错示例: ``` TypeError: Cannot read property 'length' of undefined ``` #### ✅ 原因: 你在模板中使用了 `StepForms.length`,但 `StepForms` 未初始化或为 `undefined`。 #### ✅ 修复建议: 确保 `StepForms` 初始化为空数组: ```js data() { return { searchData: { StepForms: [] } } } ``` 在模板中使用前加 `v-if` 判断: ```vue <div v-if="searchData.StepForms && searchData.StepForms.length"> <!-- 循环内容 --> </div> ``` --- ### 🧨 三、接口 404 报错(接口找不到) #### 🔍 报错示例: ``` Failed to load resource: the server responded with a status of 404 (Not Found) ``` #### ✅ 原因: 你调用了以下接口,但接口路径错误或后端未部署: ``` /api/surroundinga/erc/listPurposeCode/J2A /api/surroundinga/erc/listEquipmentType/J2A /api/surroundinga/erc/listChangeCode/J2A ``` #### ✅ 修复建议: ##### 1. 检查接口路径是否正确 确认接口路径是否正确,是否和后端约定一致。 ##### 2. 检查 API 配置文件 查看你的 `services/mlcs/myConfig.js` 或 `axios` 请求配置中是否有拼写错误。 ##### 3. 检查后端服务是否启动 确保后端服务已部署并运行,且接口路径正确。 --- ### 🧨 四、方法未定义(如 `handleCreateOk`、`handleCreateCancel`) #### 🔍 报错示例: ``` [Vue warn]: Property or method "handleCreateOk" is not defined... ``` #### ✅ 原因: 你在模板中绑定了 `@ok="handleCreateOk"`,但没有在 `methods` 中定义该方法。 #### ✅ 修复建议: ##### 在 `methods` 中添加方法: ```js methods: { handleCreateOk() { this.createVisible = false; }, handleCreateCancel() { this.createVisible = false; } } ``` --- ### 🧨 五、组件未正确引入或使用 #### 🔍 报错示例: ``` [Vue warn]: Unknown custom element: <PageToggleTransition> - did you register the component correctly? ``` #### ✅ 原因: 你使用了 `<PageToggleTransition>` 组件,但未在父组件中注册。 #### ✅ 修复建议: ##### 1. 引入组件: ```js import PageToggleTransition from '@/components/transition/PageToggleTransition.vue' ``` ##### 2. 注册组件: ```js components: { PageToggleTransition } ``` --- ## ✅ 总结修复清单 | 问题类型 | 修复方式 | |----------|----------| | `Yes`/`No` 未定义 | 在 `data()` 中定义,或使用字符串 | | `createVisible`、`loading` 未定义 | 在 `data()` 中初始化 | | `StepForms.length` 报错 | 初始化为空数组,使用 `v-if` 判断 | | `handleCreateOk` 未定义 | 在 `methods` 中添加方法 | | 接口 404 | 检查接口路径 & 后端是否部署 | | 组件未注册 | 引入并注册组件 | --- ## ✅ 建议排查顺序 1. 打开浏览器控制台 → 查看报错信息 2. 检查 `data()` 中是否定义了模板中使用的变量 3. 检查 `methods` 中是否定义了事件绑定的方法 4. 检查 `components` 是否正确引入并注册 5. 检查接口路径是否正确、后端是否正常响应 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值