<div class={`this.customerId == msg.counterpartId ? 'msg-left' : 'msg-you' }> <img src="../../../public/th.jpg" alt=""> <div class="avatar">{{ msg.counterpartId }}</div> <div class="msg-text">{{ msg.msg }}</div> </div>怎么修改
时间: 2024-03-16 09:47:14 浏览: 9
你可以修改 `class` 属性绑定的值,来修改 `div` 元素的样式类。具体来说,你可以按照以下方法修改这段代码:
```
<div :class="this.customerId === msg.counterpartId ? 'msg-left' : 'msg-you'">
<img src="../../../public/th.jpg" alt="">
<div class="avatar">{{ msg.counterpartId }}</div>
<div class="msg-text">{{ msg.msg }}</div>
</div>
```
这里使用了 `:class` 绑定语法来动态绑定样式类,类名表达式 `this.customerId === msg.counterpartId ? 'msg-left' : 'msg-you'` 会根据 `customerId` 和 `counterpartId` 的值来判断要添加的样式类。如果 `customerId` 等于 `counterpartId`,则添加 `msg-left` 样式类,否则添加 `msg-you` 样式类。
另外,注意在模板中不需要使用 `this` 关键字,只需要直接使用变量名即可。因此,你可以将 `this.customerId` 修改为 `customerId`,代码会更加简洁清晰。
相关问题
SELECT cs.taskname, rt.taskcont, rp.YEAR, rp.taskcont rpname, rp.iszb, ni.id, ifnull( ni.totalfinance, '0' ) totalfinance, ifnull( ni.centralfinance, '0' ) centralfinance, ifnull( ni.localfinance, '0' ) localfinance, ifnull( ni.investedfinance, '0' ) investedfinance, ifnull( ni.supportfinance, '0' ) supportfinance, ifnull( ni.selffinance, '0' ) selffinance, ni.statusnum FROM nk_xjsg_constask cs JOIN nk_xjsg_refinetask rt ON cs.id = rt.taskid AND cs.customerid = rt.customerid JOIN nk_xjsg_refinetask_process rp ON rt.id = rp.rtaskid AND rt.customerid = rp.customerid LEFT JOIN nk_xjsg_itembudget ni ON ni.rpid = rp.id AND ni.customerid = rp.customerid join nk_xjsg_process_leader nl on nl.itemid = rp.id and nl.customerid = rp.customerid join nk_user_info nui on nui.id = nl.tid and nui.customerid = nl.customerid where cs.pid = '40289e8c87fff7f80188042c15d50010' and ni.flowtaskid in ('40289e8b87a7c0ef0188527f09700206','40289e8b87a7c0ef018852359f600204') where cs.pid = '40289e8c87fff7f80188042c15d50010' > 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where cs.pid = '40289e8c87fff7f80188042c15d50010'' at line 33 哪里错了
根据错误提示,可以看出问题出在第二个 `where` 子句上。在 SQL 语句中,每个 `where` 子句应该只出现一次。因此,您需要删除第二个 `where` 子句,并将其与第一个 `where` 子句合并。合并后的 SQL 语句如下所示:
```
SELECT
cs.taskname,
rt.taskcont,
rp.YEAR,
rp.taskcont rpname,
rp.iszb,
ni.id,
ifnull(ni.totalfinance, '0') totalfinance,
ifnull(ni.centralfinance, '0') centralfinance,
ifnull(ni.localfinance, '0') localfinance,
ifnull(ni.investedfinance, '0') investedfinance,
ifnull(ni.supportfinance, '0') supportfinance,
ifnull(ni.selffinance, '0') selffinance,
ni.statusnum
FROM
nk_xjsg_constask cs
JOIN nk_xjsg_refinetask rt ON cs.id = rt.taskid AND cs.customerid = rt.customerid
JOIN nk_xjsg_refinetask_process rp ON rt.id = rp.rtaskid AND rt.customerid = rp.customerid
LEFT JOIN nk_xjsg_itembudget ni ON ni.rpid = rp.id AND ni.customerid = rp.customerid
JOIN nk_xjsg_process_leader nl ON nl.itemid = rp.id AND nl.customerid = rp.customerid
JOIN nk_user_info nui ON nui.id = nl.tid AND nui.customerid = nl.customerid
WHERE
cs.pid = '40289e8c87fff7f80188042c15d50010'
AND ni.flowtaskid IN ('40289e8b87a7c0ef0188527f09700206', '40289e8b87a7c0ef018852359f600204')
```
SELECT IFNULL(COUNT(DISTINCT nt.id), 0) total, IFNULL(COUNT( DISTINCT ta.id), 0) endtotal, cs.taskname, nt.id, nt.name FROM nk_xjsg_taskresult nt JOIN nk_xjsg_constask cs ON cs.id = nt.taskid AND cs.customerid = nt.customerid AND cs.pid = '40289e8c87fff7f80188042c15d50010' JOIN nk_xjsg_consplan nc ON nc.id = cs.pid AND nc.customerid = cs.customerid LEFT JOIN ( SELECT id, resultid, statusnum, statusname, endnum FROM nk_xjsg_taskresult_date WHERE customerid = '40289e8c8803a391018803a6ef8f0000' ) ta ON ta.resultid = nt.id and ta.statusnum = '40' -- AND ta.number = 1 -- AND ta.endnum = nt.resultnum WHERE nt.customerid = '40289e8c8803a391018803a6ef8f0000' GROUP BY cs.taskname, nt.id, nt.name; 怎么让endtotal的值从5变成1
根据你提供的SQL查询语句,endtotal的值是通过COUNT函数统计的DISTINCT ta.id的数量,因此结果为5。如果你想让endtotal的值从5变成1,需要在COUNT函数中加入条件,只统计符合要求的数据。根据你的需求,可以在COUNT函数的参数中加入条件“ta.endnum = nt.resultnum”,确保只统计符合要求的数据。修改后的SQL查询语句如下:
```
SELECT IFNULL(COUNT(DISTINCT nt.id), 0) total, IFNULL(COUNT(DISTINCT CASE WHEN ta.endnum = nt.resultnum THEN ta.id ELSE NULL END), 0) endtotal, cs.taskname, nt.id, nt.name
FROM nk_xjsg_taskresult nt
JOIN nk_xjsg_constask cs ON cs.id = nt.taskid AND cs.customerid = nt.customerid AND cs.pid = '40289e8c87fff7f80188042c15d50010'
JOIN nk_xjsg_consplan nc ON nc.id = cs.pid AND nc.customerid = cs.customerid
LEFT JOIN (
SELECT id, resultid, statusnum, statusname, endnum
FROM nk_xjsg_taskresult_date
WHERE customerid = '40289e8c8803a391018803a6ef8f0000'
) ta ON ta.resultid = nt.id and ta.statusnum = '40' -- AND ta.number = 1
WHERE nt.customerid = '40289e8c8803a391018803a6ef8f0000'
GROUP BY cs.taskname, nt.id, nt.name;
```
修改后的查询语句中,将第二个COUNT函数的参数改为“DISTINCT CASE WHEN ta.endnum = nt.resultnum THEN ta.id ELSE NULL END”,这样只有符合条件的数据才会被统计。