### Ray Button Event Handling
Source: https://images.tuyacn.com/rms-static/0a8ca130-992a-11f0-acc5-73add60e0a28-1758706629315
Provides an example of handling click events and asynchronous operations with the `ray-button` component. It shows how to bind a `@click` event handler and use the `loading` state to indicate processing during an asynchronous task.
```html
点击事件
{{ loading ? '处理中...' : '异步操作' }}
```
```javascript
export default {
data() {
return {
loading: false
}
},
methods: {
handleClick() {
console.log('按钮被点击了')
// 可以在这里处理点击逻辑
},
async handleAsyncClick() {
this.loading = true
try {
// 模拟异步操作
await this.mockAsyncOperation()
console.log('异步操作完成')
} catch (error) {
console.error('操作失败:', error)
} finally {
this.loading = false
}
},
mockAsyncOperation() {
return new Promise(resolve => {
setTimeout(resolve, 2000)
})
}
}
}
```
--------------------------------
### Ray Button Block Style
Source: https://images.tuyacn.com/rms-static/0a8ca130-992a-11f0-acc5-73add60e0a28-1758706629315
Demonstrates the 'block' attribute for the `ray-button` component, which makes the button occupy the full width of its parent container. This includes examples of a standard block button and a block button with a plain style.
```html
块级按钮
块级朴素按钮
```
--------------------------------
### Ray Button Icon Usage
Source: https://images.tuyacn.com/rms-static/0a8ca130-992a-11f0-acc5-73add60e0a28-1758706629315
Shows how to add icons to the `ray-button` component using the 'icon' attribute. Examples include adding a star icon, a plus icon, and a delete icon to primary, success, and danger buttons respectively.
```html
收藏
添加
删除
```
--------------------------------
### Basic Button Usage in Ray Framework
Source: https://images.tuyacn.com/rms-static/0a8ca130-992a-11f0-acc5-73add60e0a28-1758706629315
Demonstrates the fundamental usage of the `ray-button` component in a Vue.js template within the Ray framework. It shows how to render a default button and buttons with different predefined types like 'primary', 'success', 'warning', and 'danger'.
```html
默认按钮
主要按钮
成功按钮
警告按钮
危险按钮
```
--------------------------------
### Ray Button Different Types
Source: https://images.tuyacn.com/rms-static/0a8ca130-992a-11f0-acc5-73add60e0a28-1758706629315
Illustrates how to use the `ray-button` component with various `type` attributes to display different colored buttons: default, primary, success, warning, and danger. This showcases the component's theming capabilities.
```html
默认按钮
主要按钮
成功按钮
警告按钮
危险按钮
```
--------------------------------
### Customizing Ray Button Styles with CSS Variables
Source: https://images.tuyacn.com/rms-static/0a8ca130-992a-11f0-acc5-73add60e0a28-1758706629315
Demonstrates how to customize the appearance of the `ray-button` component using CSS variables. It shows overriding default variables for height, font size, border-radius, and colors for different button types, as well as creating custom gradient backgrounds.
```css
/* 按钮基础样式变量 */
.ray-button {
--button-height: 44px;
--button-font-size: 16px;
--button-border-radius: 4px;
--button-padding: 0 16px;
/* 主要按钮样式 */
--button-primary-color: #fff;
--button-primary-background: #1890ff;
--button-primary-border: #1890ff;
/* 成功按钮样式 */
--button-success-color: #fff;
--button-success-background: #52c41a;
--button-success-border: #52c41a;
/* 警告按钮样式 */
--button-warning-color: #fff;
--button-warning-background: #faad14;
--button-warning-border: #faad14;
/* 危险按钮样式 */
--button-danger-color: #fff;
--button-danger-background: #ff4d4f;
--button-danger-border: #ff4d4f;
}
/* 自定义按钮样式示例 */
.custom-button {
--button-primary-background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--button-border-radius: 20px;
}
```
--------------------------------
### Ray Button Different Sizes
Source: https://images.tuyacn.com/rms-static/0a8ca130-992a-11f0-acc5-73add60e0a28-1758706629315
Shows how to control the size of the `ray-button` component using the `size` attribute. It demonstrates the 'large', 'normal', 'small', and 'mini' size options for buttons, allowing for flexible UI design.
```html
大型按钮
普通按钮
小型按钮
迷你按钮
```
--------------------------------
### Ray Button Plain Style
Source: https://images.tuyacn.com/rms-static/0a8ca130-992a-11f0-acc5-73add60e0a28-1758706629315
Demonstrates the 'plain' attribute for the `ray-button` component, which creates a button with a hollow or outlined appearance. This is shown for primary, success, warning, and danger button types.
```html
朴素按钮
朴素按钮
朴素按钮
朴素按钮
```
--------------------------------
### Ray Button Disabled and Loading States
Source: https://images.tuyacn.com/rms-static/0a8ca130-992a-11f0-acc5-73add60e0a28-1758706629315
Illustrates how to apply disabled and loading states to the `ray-button` component. The 'disabled' attribute prevents interaction, while the 'loading' attribute shows a visual indicator and disables clicks.
```html
禁用状态
加载中
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.