简体   繁体   English

自定义 Svelte 材质 UI 滑块标签

[英]Custom Svelte material UI Slider label

I need to set custom label of smui/slider https://sveltematerialui.com/demo/slider/ in a tick marks and discrete slider.我需要在刻度线和离散滑块中设置 smui/slider https://sveltematerialui.com/demo/slider/的自定义标签。 I've found explained hot to do it in material web components https://github.com/material-components/material-components-web/tree/v13.0.0/packages/mdc-slider and it seems that is possible using setValueToAriaValueTextFn but there isn't any example, and even less using svelte.我发现在材料网络组件中解释得很热https://github.com/material-components/material-components-web/tree/v13.0.0/packages/mdc-slider似乎可以使用setValueToAriaValueTextFn但没有任何例子,更不用说使用 svelte。

How can I do it?我该怎么做?

Thank's in advance提前致谢

It is unfortunately not possible to change the tooltip text with https://sveltematerialui.com/demo/slider/ .不幸的是,无法使用https://sveltematerialui.com/demo/slider/更改工具提示文本。

The tooltip text is bound to value .工具提示文本绑定到value See here: https://github.com/hperrin/svelte-material-ui/blob/master/packages/slider/src/Slider.svelte#L181见这里: https ://github.com/hperrin/svelte-material-ui/blob/master/packages/slider/src/Slider.svelte#L181

<span class="mdc-slider__value-indicator-text">{value}</span>

The value is exported by the component and you could modify it, but this would of course only allow for numbers and would also change the current value/position of the slider -> which would mess up it's functionality.value由组件导出,您可以对其进行修改,但这当然只允许数字,并且还会更改滑块的当前值/位置 -> 这会破坏它的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM