alpine
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "alpine":https://skillpi.com/zh/skills/deepskill-bd2ee25ca70b26b6486125746f57367eb3a46f59c059d3fe7b3d79f86012ef64。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
Alpine.js:一个轻量级 JavaScript 框架,通过在 HTML 标记中使用属性提供响应式数据、事件处理和 DOM 操作,作为具有声明式语法的现代 jQuery 替代方案,用于为静态 HTML 添加交互性。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: alpine
description: |
Alpine.js is a lightweight JavaScript framework for adding interactivity to HTML
markup. It provides reactive data, event handling, and DOM manipulation through
HTML attributes — like a modern jQuery replacement with declarative syntax.
license: Apache-2.0
compatibility: 'any web server, html'
metadata:
author: terminal-skills
version: 1.0.0
category: development
tags:
- javascript
- html
- lightweight
- reactive
- declarative
- progressive-enhancementAlpine.js
Alpine.js adds reactive behavior directly in HTML markup using x- attributes. It's ideal for adding interactivity to server-rendered pages without a build step or SPA framework.
Installation
<!-- index.html — add Alpine via CDN -->
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<!-- Or: npm install alpinejs -->
// main.js — npm module setup
import Alpine from 'alpinejs';
window.Alpine = Alpine;
Alpine.start();
Core Directives
<!-- templates/basics.html — fundamental Alpine directives -->
<div x-data="{ open: false, count: 0 }">
<!-- Toggle visibility -->
<button @click="open = !open">Toggle</button>
<div x-show="open" x-transition>
<p>This content can be toggled</p>
</div>
<!-- Reactive counter -->
<p>Count: <span x-text="count"></span></p>
<button @click="count++">Increment</button>
<!-- Conditional rendering (removes from DOM) -->
<template x-if="count > 5">
<p>Count is greater than 5!</p>
</template>
</div>
Data Binding
<!-- templates/binding.html — two-way binding and attribute binding -->
<div x-data="{ name: '', color: 'blue' }">
<!-- Two-way binding -->
<input x-model="name" placeholder="Your name" />
<p>Hello, <span x-text="name || 'stranger'"></span>!</p>
<!-- Attribute binding -->
<div :class="{ 'text-red': color === 'red', 'text-blue': color === 'blue' }">
Colored text
</div>
<select x-model="color">
<option value="blue">Blue</option>
<option value="red">Red</option>
</select>
<!-- Style binding -->
<div :style="{ color: color, fontWeight: name ? 'bold' : 'normal' }">
Dynamic styles
</div>
</div>
Loops
<!-- templates/loops.html — iterating over data -->
<div x-data="{ items: ['Apples', 'Bananas', 'Cherries'], newItem: '' }">
<ul>
<template x-for="(item, index) in items" :key="index">
<li>
<span x-text="item"></span>
<button @click="items.splice(index, 1)">×</button>
</li>
</template>
</ul>
<form @submit.prevent="items.push(newItem); newItem = ''">
<input x-model="newItem" placeholder="Add item" />
<button type="submit">Add</button>
</form>
</div>
Event Handling
<!-- templates/events.html — event modifiers and custom events -->
<div x-data="{ count: 0 }">
<!-- Modifiers -->
<button @click.prevent="count++">Prevent default</button>
<button @click.once="alert('Only once!')">Click once</button>
<input @keydown.enter="submitForm()" @keydown.escape="cancel()" />
<!-- Debounce -->
<input @input.debounce.300ms="search($event.target.value)" placeholder="Search..." />
<!-- Listen to events from window -->
<div @custom-event.window="count++">
Count: <span x-text="count"></span>
</div>
<!-- Dispatch custom event -->
<button @click="$dispatch('custom-event')">Dispatch</button>
</div>
Component Patterns
<!-- templates/dropdown.html — dropdown component -->
<div x-data="{ open: false }" @click.outside="open = false">
<button @click="open = !open">
Menu
<span :class="{ 'rotate-180': open }" x-text="open ? '▲' : '▼'"></span>
</button>
<div x-show="open" x-transition.origin.top.left
@keydown.escape.window="open = false"
class="dropdown-menu">
<a href="/profile">Profile</a>
<a href="/settings">Settings</a>
<button @click="$dispatch('logout')">Logout</button>
</div>
</div>
<!-- templates/tabs.html — tabs component -->
<div x-data="{ activeTab: 'general' }">
<nav>
<button @click="activeTab = 'general'" :class="{ active: activeTab === 'general' }">General</button>
<button @click="activeTab = 'security'" :class="{ active: activeTab === 'security' }">Security</button>
</nav>
<div x-show="activeTab === 'general'">General settings...</div>
<div x-show="activeTab === 'security'">Security settings...</div>
</div>
Reusable Data with Alpine.data
<!-- templates/reusable.html — extracting reusable components -->
<script>
// Register reusable component
document.addEventListener('alpine:init', () => {
Alpine.data('todoList', () => ({
items: [],
newItem: '',
add() {
if (this.newItem.trim()) {
this.items.push({ text: this.newItem, done: false });
this.newItem = '';
}
},
remove(index) {
this.items.splice(index, 1);
},
get remaining() {
return this.items.filter(i => !i.done).length;
},
}));
});
</script>
<!-- Use anywhere -->
<div x-data="todoList">
<form @submit.prevent="add">
<input x-model="newItem" placeholder="New todo" />
<button type="submit">Add</button>
</form>
<p x-text="`${remaining} remaining`"></p>
<template x-for="(item, i) in items" :key="i">
<div>
<input type="checkbox" x-model="item.done" />
<span x-text="item.text" :class="{ 'line-through': item.done }"></span>
<button @click="remove(i)">×</button>
</div>
</template>
</div>
Working with htmx
<!-- templates/alpine-htmx.html — Alpine + htmx together -->
<div x-data="{ editing: false }" id="article-42">
<div x-show="!editing">
<h2>Article Title</h2>
<button @click="editing = true">Edit</button>
<button hx-delete="/articles/42" hx-target="#article-42" hx-swap="outerHTML">Delete</button>
</div>
<form x-show="editing" hx-put="/articles/42" hx-target="#article-42" hx-swap="outerHTML">
<input name="title" value="Article Title" />
<button type="submit">Save</button>
<button type="button" @click="editing = false">Cancel</button>
</form>
</div>
Stores (Global State)
<!-- templates/stores.html — Alpine stores for shared state -->
<script>
document.addEventListener('alpine:init', () => {
Alpine.store('notifications', {
items: [],
add(msg) { this.items.push({ text: msg, id: Date.now() }) },
remove(id) { this.items = this.items.filter(n => n.id !== id) },
});
});
</script>
<div x-data @click="$store.notifications.add('Button clicked!')">Click me</div>
<div x-data>
<template x-for="n in $store.notifications.items" :key="n.id">
<div class="toast" x-text="n.text" @click="$store.notifications.remove(n.id)"></div>
</template>
</div>
Magic Properties
<!-- templates/magic.html — Alpine magic properties -->
<div x-data="{ items: [] }">
<!-- $refs — reference DOM elements -->
<input x-ref="input" />
<button @click="$refs.input.focus()">Focus input</button>
<!-- $nextTick — run after DOM update -->
<button @click="items.push('new'); $nextTick(() => $refs.list.scrollTo(0, 99999))">
Add & scroll
</button>
<div x-ref="list" style="max-height:200px;overflow:auto">
<template x-for="item in items"><p x-text="item"></p></template>
</div>
<!-- $watch — react to data changes -->
<div x-init="$watch('items', (val) => console.log('items changed:', val))"></div>
</div>
Key Patterns
- Use
x-dataon a parent element to define reactive scope — everything inside shares that state - Use
x-showfor toggling visibility (CSS),x-iffor conditional DOM insertion - Use
x-modelfor two-way binding on inputs, selects, checkboxes - Use event modifiers (
.prevent,.stop,.debounce,.outside) to reduce boilerplate - Use
Alpine.data()to extract reusable components with methods and computed properties - Use
Alpine.store()for global state shared across components - Pairs excellently with htmx: Alpine handles UI state, htmx handles server communication
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 全面覆盖 Alpine.js 的核心功能,包括安装、指令、数据绑定、事件处理等
亮点
- 触发词精准完整,frontmatter 中 description 清晰描述了技能用途
亮点
- 结构清晰,分阶段介绍,包含端到端示例,frontmatter 完整
亮点
- 工具来源明确,参数正确,覆盖主要异常,不可逆操作有确认机制
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 31 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- cdn.jsdelivr.net
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。