渲染接口返回数据时无法显示在页面上

@Component
export class ModalDemo extends Vue {
  private count!:string;

@Prop() operateForm!: any;
  created() {
    this.form = this.$form.createForm(this, { name: 'form' });
    console.log('this.', this.operateForm);
    serviceDemo.getData3(this.operateForm).subscribe((res: any) => {
      console.log('res', res);
      this.count = res.code;
    });
  }
  
  render() {
    return (
      <div>
        {this.count}
      </div>
    );
  }
}

一开始这样写的时候,this.count总是赋值不上去,到最后才知道是定义count的时候没有赋初始值,只要在定义count的时候改成private count:string=’ ';

猜你喜欢

转载自blog.csdn.net/qq_45989814/article/details/120833970