Uncaught (in promise) TypeError: (intermediate value).setAttribute is not a function
Uncaught (in promise) TypeError: (intermediate value).setAttribute is not a function
我正在尝试在 sap.m.table 单元格中设置 "aria-selected=true",因为我希望屏幕阅读器能够读取 table 中选择的单元格。
row.addCell(new sap.m.VBox({
items: [
new sap.m.Text({
text: "cell one"
})
]
).setAttribute("aria-selected", "true"));
但是,我收到此错误 "Uncaught (in promise) TypeError: (intermediate value).setAttribute is not a function"。
我尝试通过在 sap.m.Text 之后添加一个分号来修复此问题,但这会给我一个语法错误。
setAttribute 不是行的有效函数。
但是,它是其 Dom 引用的有效函数。试试这个
row.addCell(new sap.m.VBox({
items: [
new sap.m.Text({
text: "cell one"
})
]
}).getDomRef().setAttribute("aria-selected", true);
请注意,您只能从已呈现的控件中获取 dom 引用。如果您想改为将属性设置为文本控件,则必须在初始化和呈现之后检索文本,然后再设置属性。
我正在尝试在 sap.m.table 单元格中设置 "aria-selected=true",因为我希望屏幕阅读器能够读取 table 中选择的单元格。
row.addCell(new sap.m.VBox({
items: [
new sap.m.Text({
text: "cell one"
})
]
).setAttribute("aria-selected", "true"));
但是,我收到此错误 "Uncaught (in promise) TypeError: (intermediate value).setAttribute is not a function"。
我尝试通过在 sap.m.Text 之后添加一个分号来修复此问题,但这会给我一个语法错误。
setAttribute 不是行的有效函数。
但是,它是其 Dom 引用的有效函数。试试这个
row.addCell(new sap.m.VBox({
items: [
new sap.m.Text({
text: "cell one"
})
]
}).getDomRef().setAttribute("aria-selected", true);
请注意,您只能从已呈现的控件中获取 dom 引用。如果您想改为将属性设置为文本控件,则必须在初始化和呈现之后检索文本,然后再设置属性。