在 JavaScript 中,可以使用 getAttribute() 方法来获取自定义标签的自定义属性值。
<my-tag data-custom-attribute="value"></my-tag>
<script>
var myTag = document.querySelector("my-tag");
var customAttributeValue = myTag.dataset.customAttribute;
console.log(customAttributeValue); // Output: "value"
</script>
温馨提示:答案为网友推荐,仅供参考