提交 ab8fde2b 编写于 作者: S shenjizhe

1

上级 77dbb582
......@@ -27,15 +27,6 @@
}
}
,{
"path" : "pages/test/test-er/console-view/console-view",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
......
## 1.0.1(2021-12-10)
组件方法的说明文档
## 1.0.0(2021-12-10)
控制台
<template>
<scroll-view :scroll-y="true" :scroll-top="positionY">
<textarea class="text-area" auto-height v-model="text" @linechange="onLineChange" :disabled="disabled"></textarea>
</scroll-view>
</template>
<script>
export default {
emits: ['changed'],
props: {
name: 'uConsoleView',
disabled: {
type: Boolean,
required: false,
default() {
return false;
}
},
needTime: {
type: Boolean,
required: false,
default() {
return false;
}
}
},
data() {
return {
positionY: 0,
text: ''
};
},
computed: {
_text: {
get() {
return this.texts;
},
set(val) {
this.texts = val;
}
}
},
methods: {
onLoad() {
this.texts = this.text;
},
appendText(text) {
let line = ' ';
if (this.needTime) {
let time = this.dateformat('yyyy-MM-dd hh:mm:ss.SSS', new Date());
line += time;
}
line += '\t: ' + text + '\n';
this.text += line;
this.$emit('changed', { action: 'append', text: this.text, append: text });
},
clearText() {
this.text = '';
this.$emit('changed', { action: 'clear', text: this.text });
},
onLineChange(e) {
this.positionY = e.detail.height;
},
dateformat(fmt, date) {
var o = {
'M+': date.getMonth() + 1, //月份
'd+': date.getDate(), //日
'h+': date.getHours(), //小时
'm+': date.getMinutes(), //分
's+': date.getSeconds(), //秒
'q+': Math.floor((date.getMonth() + 3) / 3), //季度
'S+': date.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ((k == 'S+' ? '000' : '00') + o[k]).substr(('' + o[k]).length));
}
}
return fmt;
}
}
};
</script>
<style>
.text-area {
width: 100%;
}
</style>
{
"id": "thirdlucky-console-view",
"displayName": "thirdlucky-console-view",
"version": "1.0.1",
"description": "thirdlucky-console-view",
"keywords": [
"thirdlucky-console-view"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-vue": "u",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
\ No newline at end of file
# thirdlucky-console-view
## ConsoleView 输出控制台
> **组件名:thirdlucky-console-view**
> 代码块: `uConsoleView`
> 作用: 可以输出日志的控制台
### 安装方式
本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`
如需通过`npm`方式使用`uni-ui`组件,另行文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55)
### 基本用法
```html
<template>
<view>
<thirdlucky-console-view class="console-view" ref="consoleView" disabled needTime @changed="onConsoleChanged"></thirdlucky-console-view>
</view>
</template>
```
```javascript
<script>
export default {
methods: {
onConsoleChanged(e){
console.log(e.action,e.text);
},
appendText(text) {
this.$refs.consoleView.appendText(text);
},
}
};
</script>
```
## API
### DataTable Props
| 属性名| 类型 |可选值 | 默认值| 说明 |示例 |
| :-: | :-: |:-: |:-: | :-: |:-: |
|disabled|Boolean|可选|false|是否禁用|true|
|needTime|Boolean|可选|false|是否打印时间|true|
#### Localdata Options
### DataTable Events
| 事件名 | 事件说明 | 返回参数 |
| :-: | :-: | :-: |
| @changed | 文本 | e.action:行为(append-添加,clear-清除),text:所有文本,append:新增的数据 |
### DataTable methods
| 方法名 | 事件说明 | 参数 |
| :-: | :-: | :-: |
| appendText | 输出文本 | text:要添加的文本 |
| clearText | 清空控制台 | |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册