手册版本 V3.0
组件名称
graceComment : /graceUI/组件目录/graceComment
组件功能
底部弹出形式的评论提交组件,包含 at、内容、图片信息;
组件属性
| 属性名称 | 类型 | 默认值 | 作用 |
| placeholder | String | 说点什么吧 | 输入框提示文本内容 |
| isImg 2020.09.22 + | Boolean | true | 是否带有图片选择功能 |
重要说明
01. uni-app 平台请在对应的页面设置 "softinputMode":"adjustResize" 解决软键盘遮盖问题
{
"pages": [
{
"path": "pages/demo/demo",
"style":{
"softinputMode":"adjustResize"
}
02. 此组件不支持自动加载请手动导入;演示代码
UNI 普通版本
NVUE 版本
微信小程序独立版本
<template>
<gracePage :customHeader="false">
<view slot="gBody" class="grace-body">
<view class="grace-title grace-margin-top">
<view class="grace-title-border"></view>
<text class="grace-title-text grace-blue">评论组件</text>
<text class="grace-text-small grace-gray">grace.hcoder.net</text>
</view>
<graceComment ref="graceComment" @submit="submit"></graceComment>
</view>
<!-- 底部提交输入框 -->
<view class="grace-nowrap grace-flex-vcenter grace-bg-white" slot="gFooter">
<view class="grace-footer-input-body" style="margin-right:25rpx;" @tap="openComment">
<text class="grace-footer-input-icon grace-icons icon-write"></text>
<input type="text" placeholder="说点什么吧..." class="grace-footer-input" disabled />
</view>
</view>
</gracePage>
</template>
<script>
import graceComment from '../../graceUI/components/graceComment.vue';
import gracePage from "../../graceUI/components/gracePage.vue";
export default{
methods:{
openComment:function () {
this.$refs.graceComment.open();
this.$refs.graceComment.setAt('GraceUI');// 设置 at 信息
},
submit : function (e) {
console.log(e);
// 评论数据以对象形式报错在 e 变量内,您可以连接 api 进行后续的功能开发
// e.at - at 用户昵称
// e.content 评论内容 , 可以此处进行字数验证
// e.img 评论图片, 临时地址,可以结合 api 进行上传
}
},
onLoad: function (){},
components:{
graceComment, gracePage
}
}
</script>
<style>
</style>
<template>
<gracePage :customHeader="false">
<view slot="gBody" class="grace-body">
<view class="grace-title grace-margin-top">
<view class="grace-title-border"></view>
<text class="grace-title-text grace-blue">评论组件</text>
<text class="grace-text-small grace-gray">grace.hcoder.net</text>
</view>
<graceComment ref="graceComment" @submit="submit"></graceComment>
</view>
<!-- 底部提交输入框 -->
<view class="grace-nowrap grace-flex-vcenter grace-bg-white" slot="gFooter">
<view class="grace-footer-input-body" style="margin-right:25rpx;" @tap="openComment">
<text class="grace-footer-input-icon grace-icons"></text>
<input type="text" placeholder="说点什么吧..." class="grace-footer-input" disabled />
</view>
</view>
</gracePage>
</template>
<script>
import graceComment from '../../graceUI/weexComponents/graceComment.nvue';
import gracePage from "../../graceUI/weexComponents/gracePage.nvue";
export default{
methods:{
openComment:function () {
this.$refs.graceComment.open();
this.$refs.graceComment.setAt('GraceUI');// 设置 at 信息
},
submit : function (e) {
console.log(e);
// 评论数据以对象形式报错在 e 变量内,您可以连接 api 进行后续的功能开发
// e.at - at 用户昵称
// e.content 评论内容 , 可以此处进行字数验证
// e.img 评论图片, 临时地址,可以结合 api 进行上传
}
},
onLoad: function (){},
components:{
graceComment, gracePage
}
}
</script>
<style>
</style>
.wxml
<gracePage customHeader="{{false}}">
<view slot="gBody" class="grace-body">
<view class="grace-title grace-margin-top">
<view class="grace-title-border"></view>
<text class="grace-title-text grace-blue">评论组件</text>
<text class="grace-text-small grace-gray">grace.hcoder.net</text>
</view>
<graceComment id="graceComment" bind:submit="submit"></graceComment>
</view>
<!-- 底部提交输入框 -->
<view class="grace-nowrap grace-flex-vcenter grace-bg-white" slot="gFooter">
<view class="grace-footer-input-body" style="margin-right:25rpx;" bindtap="openComment">
<text class="grace-footer-input-icon grace-icons icon-write"></text>
<input type="text" placeholder="说点什么吧..." class="grace-footer-input" disabled />
</view>
</view>
</gracePage>.js
Page({
data: {},
openComment:function () {
console.log(this.selectComponent('#graceComment'))
this.selectComponent('#graceComment').open();
this.selectComponent('#graceComment').setAt('GraceUI');// 设置 at 信息
},
submit : function (e) {
e = e.detail;
console.log(e);
// 评论数据以对象形式报错在 e 变量内,您可以连接 api 进行后续的功能开发
// e.at - at 用户昵称
// e.content 评论内容 , 可以此处进行字数验证
// e.img 评论图片, 临时地址,可以结合 api 进行上传
}
}).json
{
"usingComponents": {
"gracePage": "../../graceUI/components/gracePage",
"graceComment": "../../graceUI/components/graceComment"
}
}