【问题标题】:Get variable from alpine.js and add it to placeholder从 alpine.js 获取变量并将其添加到占位符
【发布时间】:2021-02-13 10:57:11
【问题描述】:

我正在尝试从 alpinejs 格式中获取一个变量以放入我的输入的占位符,代码如下:

<template x-for="(field, index) in fields" :key="index">
    <input type="text" name="sort" placeholder="<want to put index here>" />
</template>

这可能吗?

【问题讨论】:

    标签: javascript alpine.js


    【解决方案1】:

    试试这个:

    <template x-for="(field, index) in fields" :key="index">
        <input type="text" name="sort" x-bind:placeholder="index" />
    </template>
    

    【讨论】:

    • 天哪,我怎么没想到绑定 ty!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-09
    • 1970-01-01
    • 2016-08-22
    • 2015-01-18
    相关资源
    最近更新 更多