warning in ./src/router/index.js (Emitted value instead of an instance of Error) Error compiling template: Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'jsoninfo'

warning in ./src/router/index.js

WARNING Compiled with 46 warnings 18:23:38
warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

1852:4-15 "export 'onUnmounted' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

1853:4-17 "export 'onDeactivated' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

1854:4-15 "export 'onActivated' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

1867:52-70 "export 'getCurrentInstance' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

1871:25-31 "export 'inject' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

1889:52-70 "export 'getCurrentInstance' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

1893:25-31 "export 'inject' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2059:19-25 "export 'inject' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2060:25-31 "export 'inject' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2061:18-26 "export 'computed' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2061:48-53 "export 'unref' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2062:30-38 "export 'computed' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2086:21-29 "export 'computed' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2088:26-34 "export 'computed' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2093:26-31 "export 'unref' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2093:69-74 "export 'unref' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2101:25-43 "export 'getCurrentInstance' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2112:12-23 "export 'watchEffect' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2121:14-22 "export 'computed' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2127:37-52 "export 'defineComponent' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2146:21-29 "export 'reactive' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2147:28-34 "export 'inject' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2148:24-32 "export 'computed' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2161:18-19 "export 'h' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2239:37-52 "export 'defineComponent' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2255:30-36 "export 'inject' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2256:31-39 "export 'computed' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2257:22-28 "export 'inject' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2258:32-40 "export 'computed' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2259:8-15 "export 'provide' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2260:8-15 "export 'provide' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2261:8-15 "export 'provide' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2262:24-27 "export 'ref' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2265:8-13 "export 'watch' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2320:30-31 "export 'h' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2365:21-39 "export 'getCurrentInstance' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2466:8-13 "export 'watch' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

2822:25-35 "export 'shallowRef' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

3341:15-23 "export 'nextTick' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

3374:27-32 "export 'unref' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

3394:37-45 "export 'computed' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

3397:42-50 "export 'reactive' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

3454:11-17 "export 'inject' was not found in 'vue'

warning in ./node_modules/_vue-router@4.0.15@vue-router/dist/vue-router.esm-bundler.js

3461:11-17 "export 'inject' was not found in 'vue'

warning in ./src/router/index.js

4:8-14 "export 'default' (imported as 'Router') was not found in 'vue-router'

warning in ./src/router/index.js

5:19-25 "export 'default' (imported as 'Router') was not found in 'vue-router'

vue-router版本太高

cnpm install vue-router@3.5.3 -D

(Emitted value instead of an instance of Error) Error compiling template:

//子组件下只能有一个标签
<template>
	<p>这是嵌套路由</p>
	{{testdata}}
	<!--  <p>{{jsoninfo.name}}</p>-->
</template>

改为

<template>
  <div>
    <p>这是嵌套路由</p>
    {{testdata}}
    
  </div>

<!--  <p>{{jsoninfo.name}}</p>-->
</template>

Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'jsoninfo') at eval (children-router.vue?c64a:42:1)

在JS中,箭头函数并不是简单的function(){}匿名函数的简写语法,实际上,箭头函数和匿名函数有个明显区别,箭头函数内部的this是词法作用域,
在编写函数时已经确定了,而匿名函数的this指向运行时实际调用该方法的对象,无法在编写函数时确定

getData:function () {
      let s={};
      this.axios({
        method:'get',
        url:'http://localhost:8080/static/mock/testjson.json',

      }).then( function (response){
        console.log(this.jsoninfo=response.data)
        // response.data;
      })
      console.log(s)
      return s;
    }

改为

getData:function () {
      let s={};
      this.axios({
        method:'get',
        url:'http://localhost:8080/static/mock/testjson.json',

      }).then( (response)=>{
        console.log(this.jsoninfo=response.data)
        // response.data;
      })
      console.log(s)
      return s;
    }
posted @ 2022-06-07 19:47    阅读(2159)  评论(0编辑  收藏  举报