gpt4 book ai didi

javascript - 选择未显示在complete.ly 库中

转载 作者:行者123 更新时间:2023-12-03 02:00:26 27 4
gpt4 key购买 nike

我设置了一个非常简单的 complete.ly 文本框,但我的选项没有显示。我怀疑我错过了一些明显的事情。

这确实是一个非常基本的示例:

var strategyChoice = ["a", "b", "c"];

$(function() {

var pv = completely(document.getElementById('container'));

pv.onChange = function(text) {

console.log(text);

if (text === 'i') {
pv.setText('I want to'); // special case i becomes 'I want to'.
return;
}
if (text === 'I want to ') {
pv.options = ["pay", "receive"];
pv.repaint();
console.log(pv.options);
return;
}
if (["I want to pay ", "I want to receive "].includes(text)) {
pv.options = strategyChoice;
pv.repaint();
console.log(pv.options);
return;
}
}

这个fiddle显示问题。

最佳答案

看来您的主要问题是:

a) 忘记将“startFrom”属性设置为当前输入文本的长度

b) 忘记在某些选项值末尾添加空格

这是您的示例的稍微修改过的版本:

var strategyChoice = ['a', 'b', 'c'];
var pv = completely(document.getElementById('container'),{color:'black'});

pv.onChange = function(text) {
if (text === 'i' || text === 'I') {
pv.setText('I want to ');
return;
}
if (text === 'I want to ') {
pv.options = ['pay ', 'receive '];
pv.startFrom = text.length;
pv.repaint();
return;
}
if (['I want to pay ', 'I want to receive '].includes(text)) {
pv.options = strategyChoice;
pv.startFrom = text.length;
pv.repaint();
return;
}
};

pv.options = ['I want to pay ', 'I want to receive '];

setTimeout(function() {
pv.input.focus();
pv.setText('I ');
pv.repaint();
}, 0);
<script src="https://lorenzoongithub.github.io/completely/complete.ly.1.0.1.min.js"></script>
<div id='container'></div>

关于javascript - 选择未显示在complete.ly 库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50059403/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com