<template>
<gracePage :customHeader="false">
<!-- 页面主体 -->
<view slot="gBody" style="background:#F6F7F8;">
<view class="grace-margin-top header-input">
<input type="text" v-model="inputKwd" class="grace-form-input" placeholder="添加标签" @confirm="addTag" />
</view>
<view style="background:#FFFFFF; padding:25rpx;">
<view class="grace-margin-top">
<text class="grace-title">默认模式</text>
</view>
<view style="padding:15rpx 0;">
<graceTags :items="tags" @removeTag="removeTag"></graceTags>
</view>
<view class="grace-margin-top">
<text class="grace-title">配置演示</text>
</view>
<view style="padding:15rpx 0;">
<graceTags bgColor="#3688FF" borderRadius="30rpx" color="#FFFFFF" :items="tags" @removeTag="removeTag"></graceTags>
</view>
</view>
</view>
</gracePage>
</template>
<script>
import gracePage from "../../graceUI/components/gracePage.vue";
import graceTags from "../../graceUI/components/graceTags.vue";
export default {
data() {
return {
inputKwd : "",
tags : ['春暖花开', '海纳百川', '行者无疆', '春风化雨', '风和日丽']
}
},
methods:{
removeTag : function (index) {
this.tags.splice(index, 1);
},
addTag:function (e) {
console.log(e);
this.tags.push(e.detail.value);
this.inputKwd = '';
}
},
components:{
gracePage, graceTags
}
}
</script>
<style>
.header-input{padding:20rpx 100rpx;}
.grace-form-input{background:#FFFFFF; text-align:center; padding:10rpx; border-radius:30rpx;}
</style>
<template>
<gracePage :customHeader="false">
<!-- 页面主体 -->
<view slot="gBody" style="background-color:#F6F7F8;">
<view class="grace-margin-top header-input">
<input type="text" v-model="inputKwd" class="grace-form-input" placeholder="添加标签" @confirm="addTag" />
</view>
<view style="background-color:#FFFFFF; padding:25rpx;">
<view class="grace-margin-top">
<text class="grace-title">默认模式</text>
</view>
<view style="padding:15rpx 0;">
<graceTags :items="tags" @removeTag="removeTag"></graceTags>
</view>
<view class="grace-margin-top">
<text class="grace-title">配置演示</text>
</view>
<view style="padding:15rpx 0;">
<graceTags bgColor="#3688FF" color="#FFFFFF" :items="tags" @removeTag="removeTag"></graceTags>
</view>
</view>
</view>
</gracePage>
</template>
<script>
import gracePage from "../../graceUI/weexComponents/gracePage.nvue";
import graceTags from "../../graceUI/weexComponents/graceTags.nvue";
export default {
data() {
return {
inputKwd : "",
tags : ['春暖花开', '海纳百川', '行者无疆', '春风化雨', '风和日丽']
}
},
methods:{
removeTag : function (index) {
this.tags.splice(index, 1);
},
addTag:function (e) {
console.log(e);
this.tags.push(e.detail.value);
this.inputKwd = '';
}
},
components:{
gracePage, graceTags
}
}
</script>
<style>
.header-input{padding:20rpx 100rpx;}
.grace-form-input{background-color:#FFFFFF; text-align:center; padding:10rpx; border-radius:30rpx;}
</style>
.wxml
<gracePage customHeader="{{false}}">
<!-- 页面主体 -->
<view slot="gBody" style="background:#F6F7F8;">
<view class="grace-margin-top header-input">
<input type="text" value="{{inputKwd}}" class="grace-form-input" placeholder="添加标签" bindconfirm="addTag" />
</view>
<view style="background:#FFFFFF; padding:25rpx;">
<view class="grace-margin-top">
<text class="grace-title">默认模式</text>
</view>
<view style="padding:15rpx 0;">
<graceTags items="{{tags}}" bind:removeTag="removeTag"></graceTags>
</view>
<view class="grace-margin-top">
<text class="grace-title">配置演示</text>
</view>
<view style="padding:15rpx 0;">
<graceTags bgColor="#3688FF" borderRadius="60rpx" color="#FFFFFF" items="{{tags}}" bind:removeTag="removeTag"></graceTags>
</view>
</view>
</view>
</gracePage>.js
Page({
data: {
inputKwd: "",
tags: ['春暖花开', '海纳百川', '行者无疆', '春风化雨', '风和日丽']
},
removeTag: function (index) {
this.data.tags.splice(index.detail, 1);
this.setData({ tags:this.data.tags});
},
addTag: function (e) {
this.data.tags.push(e.detail.value);
this.setData({tags:this.data.tags, inputKwd : ''});
}
});.json
{
"usingComponents": {
"gracePage": "../../graceUI/components/gracePage",
"graceTags": "../../graceUI/components/graceTags"
}
}.wxss
.header-input{padding:20rpx 100rpx;}
.grace-form-input{background:#FFFFFF; text-align:center; padding:10rpx; border-radius:30rpx;}