feat: 让小程序消费运行时工作空间
This commit is contained in:
1 parent
53ee034db8
commit
c3df77e227
4 files changed
+45
-2
No files matched your search
@@ -1,6 +1,8 @@
|
||||
const { offerings } = require("../../utils/linjing-data");
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
Page({
|
||||
data: { loading: false, error: "", offerings, filtered: offerings, category: "全部" },
|
||||
switchCategory(e) { const category = e.currentTarget.dataset.category; this.setData({ category, filtered: category === "全部" ? offerings : offerings.filter((item) => item.category === category) }); },
|
||||
onLoad() { loadWorkspaceWithFallback().then((workspace) => { const items = workspace.offerings || offerings; this.setData({ offerings: items, filtered: items }); }); },
|
||||
switchCategory(e) { const category = e.currentTarget.dataset.category; const items = this.data.offerings || offerings; this.setData({ category, filtered: category === "全部" ? items : items.filter((item) => item.category === category) }); },
|
||||
open(e) { wx.navigateTo({ url: "/pages/offering/detail?id=" + e.currentTarget.dataset.id }); },
|
||||
});
|
||||
Reference in new issue
Block a user