我看到有人给了我一个负1。我是一个55岁的母亲,没有经验。我有很多技能,但这不是其中之一。我非常绝望,为了达到这一步我已经破产了。如果你帮不上忙,我接受,但请不要对我不利。我现在在哭。一些鼓励将不胜感激。我有一个页面,它在转发器上显示数据库中的项目。该代码使用从数据库中填充的几个下拉过滤器搜索项目。间歇性地,看似随机的(尽管进行了广泛的测试,但没有出现任何模式)代码无法填充随机下拉过滤器(一个或多个下拉过滤器显示默认设置,而不是从数据库中自行填充的设置)。我通过反复访问页面或反复刷新页面发现了这一点。通常代码可以工作,然后每 3 或 4 次,一个或多个下拉过滤器显示其默认设置,而不是从数据库中自行填充的设置(然后下次出错时,它可能是相同的或不同的或一组不起作用的过滤器)这是代码。在此页面上,有 3 个下拉过滤器,但我有几个这样的页面,每个页面显示和搜索不同的数据库,每个页面上最多有 10 个下拉过滤器,它们都有这个间歇性问题...... 它可能是相同或不同的一个或一组不起作用的过滤器)这是代码。在此页面上,有 3 个下拉过滤器,但我有几个这样的页面,每个页面显示和搜索不同的数据库,每个页面上最多有 10 个下拉过滤器,它们都有这个间歇性问题...... 它可能是相同或不同的一个或一组不起作用的过滤器)这是代码。在此页面上,有 3 个下拉过滤器,但我有几个这样的页面,每个页面显示和搜索不同的数据库,每个页面上最多有 10 个下拉过滤器,它们都有这个间歇性问题......
import wixData from "wix-data";
$w.onReady(function () {
$w('#iTitle')
$w('#iCounty')
$w('#iGeog')
$w('#dataset1')
$w('#text102')
});
let lastFilterTitle;
let lastFilterCounty;
let lastFilterGeog;
export function iTitle_change(event, $w) {
filter($w('#iTitle').value, lastFilterCounty, lastFilterGeog);
}
export function iCounty_change(event, $w) {
filter(lastFilterTitle, $w('#iCounty').value, lastFilterGeog);
}
export function iGeog_change(event, $w) {
filter(lastFilterTitle, lastFilterCounty, $w('#iGeog').value);
}
function filter(title, county, geog) {
if (lastFilterTitle !== title || lastFilterCounty !== county || lastFilterGeog !== geog) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.eq('title', title);
if (county)
newFilter = newFilter.eq('county', county);
if (geog)
newFilter = newFilter.eq('geog', geog);
$w('#dataset1').setFilter(newFilter)
.then(() => {
if ($w('#dataset1').getTotalCount() ===0) {
$w('#text102').show();
}
else {
$w('#text102').hide();
}
})
.catch((err) => {
console.log(err);
});
lastFilterTitle = title;
lastFilterCounty = county;
lastFilterGeog = geog;
}
}
// Run a query that returns all the items in the collection
wixData.query("Psychologists")
// Get the max possible results from the query
.limit(1000)
.ascending("title")
.distinct("title")
.then(results => {
let distinctList = buildOptions(results.items);
// unshift() is like push(), but it prepends an item at the beginning of an array
distinctList.unshift({ "value": '', "label": 'All Psychologists'});
//Call the function that builds the options list from the unique titles
$w("#iTitle").options = distinctList
});
function buildOptions(items) {
return items.map(curr => {
//Use the map method to build the options list in the format {label:uniqueTitle, valueuniqueTitle}
return { label: curr, value: curr };
})
}
// Run a query that returns all the items in the collection
wixData.query("Psychologists")
// Get the max possible results from the query
.limit(1000)
.ascending("county")
.distinct("county")
.then(results => {
let distinctList = buildOptions(results.items);
// unshift() is like push(), but it prepends an item at the beginning of an array
distinctList.unshift({ "value": '', "label": 'All Counties'});
//Call the function that builds the options list from the unique titles
$w("#iCounty").options = distinctList
});
function buildOptions1(items) {
return items.map(curr => {
//Use the map method to build the options list in the format {label:uniqueTitle1, valueuniqueTitle1}
return { label: curr, value: curr };
})
}
// Run a query that returns all the items in the collection
wixData.query("Psychologists")
// Get the max possible results from the query
.limit(1000)
.ascending("geog")
.distinct("geog")
.then(results => {
let distinctList = buildOptions(results.items);
// unshift() is like push(), but it prepends an item at the beginning of an array
distinctList.unshift({ "value": '', "label": 'All Regions'});
//Call the function that builds the options list from the unique titles
$w("#iGeog").options = distinctList
});
function buildOptions2(items) {
return items.map(curr => {
//Use the map method to build the options list in the format {label:uniqueTitle2, valueuniqueTitle2}
return { label: curr, value: curr };
})
}
export function button45_click(event, $w) {
//Add your code for this event here:
filter($w('#iTitle').value='', $w('#iCounty').value='', $w('#iGeog').value='');
}
我的经验和知识非常有限,所以答案可能很简单。任何帮助将不胜感激,因为如果我找不到解决方案,我将不得不放弃我的项目。谢谢