weight
权重表示一条路径的重要程度,值越高表示优先级越高。在计算两个产品的分数时,weight
会被用来加权。 在路径匹配时,getPathsWithParams
函数会按照weight
从大到小的顺序排序。
const path = new OnPathBehavior(weight)
weight
: 数字类型,表示路径的权重。const path1 = new OnPathBehavior(5)
const path2 = new OnPathBehavior(10)
console.log(path1.weight) // output: 5
console.log(path2.weight) // output: 10
weight
只能是数字类型。weight
的值为1
,表示同等重要。getPathsWithParams
函数排序前,必须先设置weight
。