小编Lyn*_*don的帖子

为什么“禁用:”顺风前缀在我的反应应用程序中不起作用?

我试图在某些情况下禁用提交按钮,但它不起作用。当我在浏览器中检查元素时,无论条件返回 true 还是 false,都会呈现这个元素。

在浏览器中呈现的元素

<button type="submit" disabled="" class="bg-yellow-500 text-white mt-4 disabled:bg-yellow-300 px-3 py-2 rounded-md">Submit</button>
Run Code Online (Sandbox Code Playgroud)

代码

state = {
        formIsVaild: false
    }

render() {
    <button type="submit" disabled={!this.state.formIsVaild} className="bg-yellow-500 text-white mt-4 disabled:bg-yellow-300 px-3 py-2 rounded-md">Open Discussion</button>
}
Run Code Online (Sandbox Code Playgroud)

我什至删除了条件并尝试了这个......

state = {
        formIsVaild: false
    }

render() {
    <button type="submit" disabled className="bg-yellow-500 text-white mt-4 disabled:bg-yellow-300 px-3 py-2 rounded-md">Open Discussion</button>
}
Run Code Online (Sandbox Code Playgroud)

无论我传递给 disable 属性的值是什么,disabled=""get 都会在 HTML 中呈现。我什至尝试使用类型为 submit 的输入而不是按钮,我得到了相同的结果。我不确定这里发生了什么......有什么帮助吗?

最小的例子

import React, { Component } from 'react';

class FormData extends Component { …
Run Code Online (Sandbox Code Playgroud)

reactjs tailwind-css

2
推荐指数
1
解决办法
1623
查看次数

无法在 Object.eval [as updateRenderer] 中读取未定义的属性“title”

我正在尝试获取单个帖子的详细信息,但我不断收到此错误;错误类型错误:无法读取 Object.eval [as updateRenderer] 中未定义的属性“title”。虽然数据在 console.log 中被正确获取,但它没有显示在页面本身上。当我执行 {{post?.title}} 时,错误消失了,但结果仍然没有出现在页面上,但在 console.log 中正确显示

离子框架:v4 操作系统平台:Windows 10

售后服务

getAllPosts(): Observable<any> {
    return this.http.get(`${this.url}`).pipe(
      map(results => {
        console.log('Raw: ', results);
        return results['posts'];
      })
    );
  }

  getPost(postId: string) {
    return this.http.get(`${this.url}/${postId}`);
  }
Run Code Online (Sandbox Code Playgroud)

post.page.ts

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { PostService } from '../post.service';

@Component({
  selector: 'app-post',
  templateUrl: './post.page.html',
  styleUrls: ['./post.page.scss'],
})
export class PostPage implements OnInit {
  loadedPost: any;

  constructor(private activatedRoute: ActivatedRoute, private postService: PostService) { …
Run Code Online (Sandbox Code Playgroud)

ionic-framework angular

1
推荐指数
1
解决办法
4773
查看次数

标签 统计

angular ×1

ionic-framework ×1

reactjs ×1

tailwind-css ×1