4 Star 12 Fork 2

Gitee 极速下载/alpine-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/alpinejs/alpine
克隆/下载
morph.html 2.18 KB
一键复制 编辑 原始数据 按行查看 历史
<html>
<script src="./packages/morph/dist/cdn.js" defer></script>
<script src="./packages/alpinejs/dist/cdn.js" defer></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js" defer></script> -->
<div id="before">
<!-- Before markup goes here: -->
<ul>
<li data-key="1">foo<input></li>
</ul>
</div>
<div id="after" style="display: none;">
<!-- After markup goes here: -->
<ul>
<li data-key="2">bar<input></li>
<li data-key="3">baz<input></li>
<li data-key="1">foo<input></li>
</ul>
</div>
<div id="b"></div>
<div style="display: flex;">
<pre id="log-from"></pre>
<pre id="log-to"></pre>
<ul id="log-message"></ul>
</div>
<div style="position: absolute; bottom: 0; left: 0; padding: 1rem; width: 100vw; background: gray; box-sizing: border-box;">
<button onclick="start()">Start</button>
<button onclick="next()">Next Step</button>
</div>
<script>
function start() {
Alpine.morph.log((message, from, to) => {
console.log(message, from, to)
document.querySelector('#log-from').innerHTML = escape(from.outerHTML)
document.querySelector('#log-to').innerHTML = escape(to.outerHTML)
let li = document.createElement('li')
li.textContent = message
message && document.querySelector('#log-message').appendChild(li)
})
Alpine.morph(
document.querySelector('#before').firstElementChild,
document.querySelector('#after').firstElementChild.outerHTML,
{ debug: true, key(el) { return el.dataset.key } }
)
}
function next() {
Alpine.morph.step()
setTimeout(() => window.dispatchEvent(new CustomEvent('refresh', { bubbles: true })))
}
function escape(unsafe) {
return unsafe
.replace(/\n/g, "\n")
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
</script>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/alpine-js.git
[email protected]:mirrors/alpine-js.git
mirrors
alpine-js
alpine-js
main

搜索帮助