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

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

Typescript 類型錯誤屬性不存在

Typescript 類型錯誤屬性不存在

回首憶惘然 2023-07-14 14:58:33
我的 Typescript Next 項目中有這個組件import PageTitle from './pagetitle'import style from './contact.styl'export default function Contact() {  return (    <section>      <a name="contact"></a>      <div className={style.container}>    <PageTitle title='get in touch!'/>        <form action="">          <input name="name" type="text" placeholder="name" />          <input name="subject" type="text" placeholder="subject" />          <textarea placeholder="message" />          <button type="submit">send</button>        </form>      </div>    </section>  );}這contact.styl看起來像是使用 Stylus CSS 預處理器的 CSS 文件,因此樣式拼寫沒有拼寫錯誤。我最近使用“next-env.d.ts”文件中的模塊聲明修復了一個錯誤.container    width 95vw    height 90vh    display flex    flex-direction column    background rgba(43,43,43,.97)    border-radius 60px    margin 0 auto    h3        font-size 22px        color #d3ecf7form    height 450px    display flex    flex-direction column    justify-content space-evenly    align-items center    margin-top 3rem    input, textarea        width 355px        box-shadow 0px 3px 6px #00000029        border-radius 13px        outline none        border none        background #2b2b2b        font normal normal 300 20px Avenir        padding-top 5px        text-align center        color #fff    input        height 45px    textarea        height 200px        resize none    ::placeholder        text-align center        font normal normal 300 20px Avenir        color #d3ecf7@media(max-width 760px)    .container        width 100vw        height auto        border-radius 0                form        height 500px        margin-top 0         input, textarea            width 90vw但我一直收到這個錯誤?Type error: Property 'container' does not exist on type 'string'.誰能幫我找出原因嗎?編輯:添加contact.styl 找出問題所在Try to add an asterisk to the module name as in the updated example. **- Sergey**
查看完整描述

1 回答

?
忽然笑

TA貢獻1806條經驗 獲得超5個贊

似乎您在聲明.d.ts文件中的某處有一個模塊聲明。它可能看起來像這樣:


declare module ".styl" {

  const value: string;

  export default value;

}

如果這是正確的,您應該將導出類型更改為Record<string, string>. 像這樣:


declare module "*.styl" {

  const value: {[key: string]: string};

  export default value;

}


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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