Loading...
Loading...
Compare original and translation side by side
use:<script>
import ImageZoom from 'js-image-zoom';
function useZoom(options) {
return (element) => {
new ImageZoom(element, options);
return () => console.log('cleanup');
};
}
</script>
<!-- Re-runs if options changes (use: wouldn't!) -->
<figure {@attach useZoom({ width: 400 })}>
<img src="photo.jpg" alt="zoomable" />
</figure>use:<script>
\timport ImageZoom from 'js-image-zoom';
\tfunction useZoom(options) {
\t\treturn (element) => {
\t\t\tnew ImageZoom(element, options);
\t\t\treturn () => console.log('cleanup');
\t\t};
\t}
</script>
<!-- 当options变化时重新运行(use:不会!) -->
<figure {@attach useZoom({ width: 400 })}>
\t<img src="photo.jpg" alt="zoomable" />
</figure>| Directive | Purpose | Reactive? |
|---|---|---|
| DOM manipulation, 3rd-party | Yes |
| Render raw HTML strings | Yes |
| Render snippets | Yes |
| Local constants in blocks | N/A |
| Pause debugger on value change | N/A |
| Keyed iteration (always key!) | Yes |
| Window event listeners | N/A |
| 指令 | 用途 | 响应式? |
|---|---|---|
| DOM操作、第三方库 | 是 |
| 渲染原始HTML字符串 | 是 |
| 渲染代码片段 | 是 |
| 代码块中的本地常量 | 不适用 |
| 值变化时暂停调试器 | 不适用 |
| 带键的迭代(务必使用键!) | 是 |
| 窗口事件监听器 | 不适用 |
| Feature | | |
|---|---|---|
| Re-runs on arg change | No | Yes |
| Composable | Limited | Fully |
| Pass through props | Manual | Auto via spread |
| Convert legacy | N/A | |
| 特性 | | |
|---|---|---|
| 参数变化时重新运行 | 否 | 是 |
| 可组合性 | 有限 | 完全支持 |
| 传递props | 手动 | 通过展开自动传递 |
| 转换旧版动作 | 不适用 | |
@attachfromActionsvelte/attachments<svelte:window><svelte:document>$effect@attachsvelte/attachmentsfromAction()<svelte:window><svelte:document>$effect