跳过主要内容

.vars

.vars: 对象

[只读] 用于创建 SplitText 实例的 vars 配置对象

细节

[只读] 用于创建 SplitText 实例的 vars 配置对象。

示例

let splitText = SplitText.create({
type: "chars,words",
wordsClass: "word++",
});

console.log(splitText.vars); // {type: "chars,words",wordsClass: "word++",}

如果需要,你可以在vars对象如果你愿意的话;SplitText 只会忽略它不认识的属性。例如,你可以添加一个 "group" 属性,以便对你的 Split 进行分组,然后之后若想销毁某一特定组的所有 SplitText 实例,你可以这样做:

// helper function (reusable):
let getGroup = (group) =>
SplitText.getAll().filter((t) => t.vars.group === group);

// then, to kill() anything with a group of "my-group":
getGroup("my-group").forEach((t) => t.kill());
无噪 Logo
无噪文档
中文文档 · 复刻官网
查看所有 ↗