所以Vue可以将一个对象添加到对象列表中,但是无论我做什么,它似乎都不会排序或追加到列表的顶部。
集合发生在这里
$metro = 'greatesthits'
$URL = "https://triplem.scadigital.com.au/stations/$metro/live"
Add-Type -path 'C:\Users\makean\Downloads\htmlagilitypack.1.8.10\lib\Net45\HtmlAgilityPack.dll'
$doc = New-Object HtmlAgilityPack.HtmlDocument
$wc = New-Object System.Net.WebClient
$doc.LoadHtml($wc.DownloadString($url))
$doc.DocumentNode.SelectNodes(".//*[contains(@class,'sc-bdVaJa iHZvIS')]")
然后我有一个计算函数排序
watch: {
sendBetData() {
// Creates the object to be appended to the list
const latest = {
bet_id: this.sendBetData.bet_id,
username: this.sendBetData.username,
bet: this.sendBetData.bet_amount,
client_seed: this.sendBetData.client_seed.seed,
created_at: this.sendBetData.created_at,
high: this.sendBetData.high,
multiplier: this.sendBetData.multiplier,
profit: this.sendBetData.profit,
result: this.sendBetData.result,
roll: this.sendBetData.roll_number,
server_seed: this.sendBetData.server_seed.seed_hash,
threshold: this.sendBetData.threshold,
user_id: this.sendBetData.user_id
};
this.$set(this.bets, latest.bet_id, latest)
},
},
但是无论我尝试什么,它总是将其设置在视图列表的底部
答案 0 :(得分:0)
如果您有一个对象数组,只需将其推入即可:
this.bets.push(latest)
此外,鉴于您要执行的操作,您的orderBy
方法可能应该是sortBy
:
return _.sortBy(this.bets, bet => bet.created_at)