禁止在JSX中使用多行JS表达式 [英] Multiline JS expressions inside JSX are forbidden

查看:243
本文介绍了禁止在JSX中使用多行JS表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用tslint检查我的React Typescript应用程序.我创建了它,并且它起作用了,但是我从tslint收到了消息:禁止在JSX中使用多行JS表达式".我不知道应该如何更改代码,以免收到tslint消息.发生的代码是:

I use tslint to check my react typescript app. I created this and it works but i get this message from tslint: "Multiline JS expressions inside JSX are forbidden". I wonder how I should change the code so I don't get tslint message. The code where it occurs is:

<MDBCol size="12">
              {pubItem ? (
                <table className="pubDetails w-100">
                  <tbody>
                    <tr>
                      <th className="pubHead w-25">Publicatie ID:</th>
                      <td className="pubItems w-25">
                        {pubItem.publicationId ? pubItem.publicationId : "Geen"}
                      </td>
                    </tr>
                    <tr>
                      <th className="pubHead">Publicatie Naam:</th>
                      <td className="pubItems">
                        {pubItem.publicationName
                          ? pubItem.publicationName
                          : "Geen"}
                      </td>
                    </tr>
                </tbody>
              </table>
            ) : null}
         </MDBCol>

推荐答案

{pubItem.publicationName ? pubItem.publicationName : "Geen"}也许是ts的分配问题.

{pubItem.publicationName ? pubItem.publicationName : "Geen"} Maybe it's assignment problem of ts.

您可以尝试在项目tslint.json中创建tslint.json.可以在此文件中对其进行配置. 例如:

You could try create tslint.json in your project tslint.json.You can configure it in this file. For Example:

这篇关于禁止在JSX中使用多行JS表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆