vue 动态设置组件高度_高度动态的Vue明星评分组件

本文介绍了一个高度可定制的Vue组件——vue-dynamic-star-rating,它类似于Google Play的评分系统。组件可通过NPM安装并全局注册,支持默认值设置,允许开发者自定义样式,并提供了基础用法和实施示例。
摘要由CSDN通过智能技术生成

vue 动态设置组件高度

虚拟动态星级 (vue-dynamic-star-rating)

A Highly Customizable, easy-to-use elegant stars rating component (similar to Google Play)

高度可定制,易于使用的优雅星级评定组件(类似于Google Play)

用法 (Usage)

Install via NPM npm i vue-dynamic-star-rating

通过NPM npm i vue-dynamic-star-rating

Then require in your project:

然后在您的项目中要求:

var StarRating = require('vue-dynamic-star-rating');

or ES6 syntax:

或ES6语法:

import StarRating from 'vue-dynamic-star-rating'

Then you can register the component globally:

然后,您可以全局注册该组件:

Vue.component('star-rating', StarRating);

Or in your Vue component:

或在您的Vue组件中:

components: {
  StarRating
}

You can then use the following selector anywhere in your project:

然后,您可以在项目中的任何地方使用以下选择器:

  • To get up and running quick the package now supports rendering just the selector with default values

    为了快速启动和运行,该软件包现在支持仅渲染具有默认值的选择器

<star-rating></star-rating>

文件 (Docs)

config: {...} is a configuration object that is to be binded to vue-star-rating, api properties are:

config: {...}是要绑定到vue-star-rating的配置对象,api属性为:

基本 (Basics)

PropertyTypeDescriptionDefault
ratingnumberA number between 0.0-5.0 that will determine the fullness of the 5-stars rating polygons1
属性 类型 描述 默认
评分 0.0-5.0之间的数字将确定5星评级多边形的充满度 1个

定制样式 (Customized Styling)

PropertyTypeDescriptionDefault
fullStarColorstringSet the full or partially-full star color#ed8a19
emptyStarColorstringSet the empty or partially-empty star color#737373
starWidthnumberSet the star width20
starHeightnumberSet the star height20
属性 类型 描述 默认
fullStarColor 设置全彩或部分全彩 #ed8a19
空的StarColor 设置空或部分空的星形颜色 #737373
starWidth 设置星宽 20
starHeight 设置星星高度 20

实施实例 (Implementation Example)

Define your config options object in the component importing StarRating e.g

在导入StarRating的组件中定义您的配置选项对象,例如

data: function() {
    return {
        config: {
            rating: 4.7,
            style: {
                fullStarColor: '#ed8a19',
                emptyStarColor: '#737373',
                starWidth: 30,
                starHeight: 30
            }
        }
    }
}

And bind it to the selector like so

然后像这样将其绑定到选择器

<star-rating :config="config"></star-rating>

翻译自: https://vuejsexamples.com/a-highly-dynamic-vue-stars-rating-component/

vue 动态设置组件高度

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值