select some api
This commit is contained in:
5
uni_modules/uni-title/changelog.md
Normal file
5
uni_modules/uni-title/changelog.md
Normal file
@@ -0,0 +1,5 @@
|
||||
## 1.0.2(2021-05-12)
|
||||
- 新增 示例地址
|
||||
- 修复 示例项目缺少组件的Bug
|
||||
## 1.0.1(2021-02-05)
|
||||
- 调整为uni_modules目录规范
|
||||
171
uni_modules/uni-title/components/uni-title/uni-title.vue
Normal file
171
uni_modules/uni-title/components/uni-title/uni-title.vue
Normal file
@@ -0,0 +1,171 @@
|
||||
<template>
|
||||
<view class="uni-title__box" :style="{'align-items':textAlign}">
|
||||
<text class="uni-title__base" :class="['uni-'+type]" :style="{'color':color}">{{title}}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* Title 章节标题
|
||||
* @description 章节标题,通常用于记录页面标题,使用当前组件,uni-app 如果开启统计,将会自动统计页面标题
|
||||
* @tutorial https://ext.dcloud.net.cn/plugin?id=1066
|
||||
* @property {String} type = [h1|h2|h3|h4|h5] 标题类型
|
||||
* @value h1 一级标题
|
||||
* @value h2 二级标题
|
||||
* @value h3 三级标题
|
||||
* @value h4 四级标题
|
||||
* @value h5 五级标题
|
||||
* @property {String} title 章节标题内容
|
||||
* @property {String} align = [left|center|right] 对齐方式
|
||||
* @value left 做对齐
|
||||
* @value center 居中对齐
|
||||
* @value right 右对齐
|
||||
* @property {String} color 字体颜色
|
||||
* @property {Boolean} stat = [true|false] 是否开启统计功能呢,如不填写type值,默认为开启,填写 type 属性,默认为关闭
|
||||
*/
|
||||
export default {
|
||||
name:"UniTitle",
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
align: {
|
||||
type: String,
|
||||
default: 'left'
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: '#333333'
|
||||
},
|
||||
stat: {
|
||||
type: [Boolean, String],
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
textAlign() {
|
||||
let align = 'center';
|
||||
switch (this.align) {
|
||||
case 'left':
|
||||
align = 'flex-start'
|
||||
break;
|
||||
case 'center':
|
||||
align = 'center'
|
||||
break;
|
||||
case 'right':
|
||||
align = 'flex-end'
|
||||
break;
|
||||
}
|
||||
return align
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
title(newVal) {
|
||||
if (this.isOpenStat()) {
|
||||
// 上报数据
|
||||
if (uni.report) {
|
||||
uni.report('title', this.title)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.isOpenStat()) {
|
||||
// 上报数据
|
||||
if (uni.report) {
|
||||
uni.report('title', this.title)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isOpenStat() {
|
||||
if (this.stat === '') {
|
||||
this.isStat = false
|
||||
}
|
||||
let stat_type = (typeof(this.stat) === 'boolean' && this.stat) || (typeof(this.stat) === 'string' && this.stat !==
|
||||
'')
|
||||
if (this.type === "") {
|
||||
this.isStat = true
|
||||
if (this.stat.toString() === 'false') {
|
||||
this.isStat = false
|
||||
}
|
||||
}
|
||||
|
||||
if (this.type !== '') {
|
||||
this.isStat = true
|
||||
if (stat_type) {
|
||||
this.isStat = true
|
||||
} else {
|
||||
this.isStat = false
|
||||
}
|
||||
}
|
||||
return this.isStat
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* .uni-title {
|
||||
|
||||
} */
|
||||
.uni-title__box {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding: 8px 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.uni-title__base {
|
||||
font-size: 15px;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.uni-h1 {
|
||||
font-size: 20px;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.uni-h2 {
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.uni-h3 {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
/* font-weight: 400; */
|
||||
}
|
||||
|
||||
.uni-h4 {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
/* font-weight: 300; */
|
||||
}
|
||||
|
||||
.uni-h5 {
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
/* font-weight: 200; */
|
||||
}
|
||||
</style>
|
||||
84
uni_modules/uni-title/package.json
Normal file
84
uni_modules/uni-title/package.json
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"id": "uni-title",
|
||||
"displayName": "uni-title 章节标题",
|
||||
"version": "1.0.2",
|
||||
"description": "章节标题,通常用于记录页面标题,使用当前组件,uni-app 如果开启统计,将会自动统计页面标题",
|
||||
"keywords": [
|
||||
"uni-ui",
|
||||
"uniui",
|
||||
"标题",
|
||||
"章节",
|
||||
"章节标题",
|
||||
""
|
||||
],
|
||||
"repository": "https://github.com/dcloudio/uni-ui",
|
||||
"engines": {
|
||||
"HBuilderX": ""
|
||||
},
|
||||
"directories": {
|
||||
"example": "../../temps/example_temps"
|
||||
},
|
||||
"dcloudext": {
|
||||
"category": [
|
||||
"前端组件",
|
||||
"通用组件"
|
||||
],
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "无",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y"
|
||||
},
|
||||
"client": {
|
||||
"App": {
|
||||
"app-vue": "y",
|
||||
"app-nvue": "y"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "y",
|
||||
"Android Browser": "y",
|
||||
"微信浏览器(Android)": "y",
|
||||
"QQ浏览器(Android)": "y"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "y",
|
||||
"IE": "y",
|
||||
"Edge": "y",
|
||||
"Firefox": "y",
|
||||
"Safari": "y"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "y",
|
||||
"阿里": "y",
|
||||
"百度": "y",
|
||||
"字节跳动": "y",
|
||||
"QQ": "y"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
71
uni_modules/uni-title/readme.md
Normal file
71
uni_modules/uni-title/readme.md
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
|
||||
## Title 章节标题
|
||||
> **组件名:uni-title**
|
||||
> 代码块: `uTitle`
|
||||
|
||||
|
||||
章节标题,通常用于记录页面标题,使用当前组件,uni-app 如果开启统计,将会自动统计页面标题 。
|
||||
|
||||
### 安装方式
|
||||
|
||||
本组件符合[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)
|
||||
|
||||
### 基本用法
|
||||
|
||||
在 ``template`` 中使用组件
|
||||
|
||||
```html
|
||||
<uni-title title="上报统计数据"></uni-title>
|
||||
<uni-title type="h1" title="h1 一级标题 "></uni-title>
|
||||
<uni-title type="h1" title="h1 一级标题" color="#027fff"></uni-title>
|
||||
<uni-title type="h2" title="h2 居中" align="center"></uni-title>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### 标题统计
|
||||
title 组件可以与 uni统计集合使用,只要开启uni统计,即可自动采集标题
|
||||
|
||||
- 如果不写 type 属性, 为上报标题。这是标题统计的默认用法,页面会优先上报组件传入的title值为统计上报数据
|
||||
- 页面统计上报只会上报一次,如多个组件开启,则只上报最后一个组件的内容,所以如非必要请不要多个组件同时开启统计,避免上报错误标题统计
|
||||
- 为避免上报错误标题统计, uni.report() API 与章节标题组件请勿一起使用
|
||||
|
||||
> **注意事项**
|
||||
> - 在使用 align 属性时,在非 nvue 页面下不生效,或者组件宽度不对,请在组件外层设置一个元素的 display为block 即可解决问题。
|
||||
>
|
||||
> **示例:**
|
||||
>
|
||||
> ```html
|
||||
> <template>
|
||||
> <view class="box">
|
||||
> <uni-title type="h1" title="h1 一级标题 "></uni-title>
|
||||
> </view>
|
||||
> </template>
|
||||
> <style>
|
||||
> .box {
|
||||
> /* #ifndef APP-NVUE */
|
||||
> display: block;
|
||||
> /* #endif */
|
||||
> }
|
||||
> </style>
|
||||
> ```
|
||||
|
||||
|
||||
## API
|
||||
### Title Props
|
||||
|
||||
|属性名 |类型 |默认值 |说明 |
|
||||
|:-: |:-: |:-: |:-: |
|
||||
|type |String |- |标题类型,可选值 h1、h2、h3、h4、h5 ,章节标题字体会比正常字长字体粗,不指定 type 值,默认为上报统计数据 |
|
||||
|title |String |- |章节标题内容 |
|
||||
|align |String |- |对齐方式,可选值 left:左对齐;center:居中;right:右对齐; |
|
||||
|color |String |- |字体颜色 |
|
||||
|stat |Boolean|- |是否开启统计功能呢,如不填写type值,默认为开启,填写 type 属性,默认为关闭 |
|
||||
|
||||
## 组件示例
|
||||
|
||||
点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/title/title](https://hellouniapp.dcloud.net.cn/pages/extUI/title/title)
|
||||
Reference in New Issue
Block a user