亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

問:錯誤:意外的令牌。預期是構造函數、方法、訪問器或屬性。ts(1068)

問:錯誤:意外的令牌。預期是構造函數、方法、訪問器或屬性。ts(1068)

慕碼人8056858 2023-06-15 16:16:51
我的代碼向我顯示此錯誤“意外的標記。預期是構造函數、方法、訪問器或屬性。ts(1068)class animal {constructor(especie,edad,color){    this.especie = especie;    this.edad = edad;    this.color = color;    this.info = `Soy un ${this.especie}, tengo ${this.edad}    y soy de color ${this.color}`;}this.verInfo = ()=>{    document.write(this.verInfo);}}錯誤顯示在這個.verInfo中
查看完整描述

1 回答

?
炎炎設計

TA貢獻1808條經驗 獲得超4個贊

你想重寫它如下:


也許在這里閱讀有關課程的信息。這是一個非常好的開始參考:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes


您也可以重命名animal為Animal.


   class Animal {

    constructor(especie,edad,color){

        this.especie = especie;

        this.edad = edad;

        this.color = color;

        this.info = `Soy un ${this.especie}, tengo ${this.edad}

        y soy de color ${this.color}`;

    }

    verInfo = () =>{

        document.write(this.verInfo);

    }

   }


查看完整回答
反對 回復 2023-06-15
  • 1 回答
  • 0 關注
  • 174 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號