首页 > 解决方案 > 我无法在 Alpine JS 中确定此消息的原因

问题描述

我收到此错误,不知道如何解决:

alpine.js:115 Alpine Error: "ReferenceError: Invalid left-hand side in assignment"

Expression: "getTasks() = rightSideOfExpression($event, getTasks())"
Element: <input class=​&quot;shadow appearance-none border rounded w-1/​3 py-2 px-2 my-1 mx-1 text-gray-700 leading-tight focus:​outline-none focus:​shadow-outline" id=​&quot;valorvenda" type=​&quot;text" placeholder=​&quot;Valor" autofocus x-ref=​&quot;valorvenda" @keydown.enter=​&quot;addTask($refs.valorvenda.id)​&quot;>​
u @ alpine.js:115
(anonymous) @ alpine.js:132

    <input class="shadow appearance-none border rounded w-1/3 py-2 px-2 my-1 mx-1 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="valorvenda" type="text" placeholder="Valor" autofocus="" x-ref="valorvenda" @keydown.enter="addTask($refs.valorvenda.id)">

VM5454749:3 Uncaught (in promise) ReferenceError: Invalid left-hand side in assignment
    at eval (eval at d.el (alpine.js:174), <anonymous>:3:21)
    at d.el (alpine.js:174)
    at d (alpine.js:131)
    at alpine.js:151
    at be.evaluateCommandExpression (alpine.js:1760)
    at z (alpine.js:933)
    at HTMLDivElement.l (alpine.js:909)

并且不知道我在做什么!你能帮我吗?

标签: javascriptalpine.js

解决方案


您可能打算比较而不是分配。更改===

getTasks() == rightSideOfExpression($event, getTasks())

推荐阅读