The development server has disconnected. Refresh the page if necessary.

在idea的控制台输入umi dev

 

在网页中输入网址http://localhost:8000之后

问题如下,当我刷新页面后,没有结果

 

生成的index.js,改了之后是这样的

@T // 通过@符号进行引用该方法,类似java中的注释
class User{
  constructor(name, age = 20) {
    this.name = name;
    this.age = age;
  }
}

function T(target) { // 定义一个普通的方法
  console.log(target); // target对象为修饰的目标对象,这里是user对象
  target.country = "中国"; // 为User类添加一个静态属性country
}

console.log(User.country); // 打印出country属性值

原因是因为原来生成的index.js文件中有一句:

export default ()=><div></div>;

所以只要在index.js文件的开头位置加上即可

效果如下:

 

posted @ 2021-01-13 20:00  谜语+  阅读(994)  评论(0编辑  收藏  举报