国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

uniapp----微信小程序 日歷組件(周日歷&& 月日歷)【Vue3+ts+uView】

這篇具有很好參考價值的文章主要介紹了uniapp----微信小程序 日歷組件(周日歷&& 月日歷)【Vue3+ts+uView】。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

uniapp----微信小程序 日歷組件(周日歷&& 月日歷)【Vue3+ts+uView】

  1. 用Vue3+ts+uView來編寫日歷組件;
  2. 存在周日歷和月日歷兩種顯示方式;
  3. 高亮顯示當(dāng)天日期,紅點(diǎn)渲染有數(shù)據(jù)的日期,點(diǎn)擊顯示數(shù)據(jù)

1. calendar-week-mouth組件代碼

<template>
    <view class="calender-container">
        <view class="calender-content">
            <!-- 頭部 -->
            <view class="calender-title" v-if="isWeek">
                <view class="calender-title-left">{{ checkedDay }}</view>
                <view class="calender-title-morebtn" v-if="isMorebtn" @click="toggleMove">更多</view>
                <view class="calender-title-right" @click="popupShowBtn" v-if="ispopupShow">?</view>
            </view>
            <view class="calender-title" v-if="!isWeek">
                <view class="calender-title-chevronl" @click="changeMonth(-1)">
                    <text class="iconfont icon-back text-[28rpx]"></text>
                </view>
                <view class="calender-title-mouth">{{ MoutnTitle }}</view>
                <view class="calender-title-chevronr calender-title-chevronr-right">
                    <text class="iconfont icon-right text-[28rpx]" @click="changeMonth(1)"></text>
                </view>
            </view>
            <!-- 星期頭部 -->
            <view class="calender-week-head">
                <view class="calender-week-head-item" v-for="(item, index) in WEEK_LIST" :key="index">
                    {{ item.text }}
                </view>
            </view>

            <transition name="fade">
                <view class="calender-month-container" :class="{ transition: transition }" :style="{
                    height: isWeek ? '120rpx' : '540rpx'
                }">
                    <view v-for="(month, index) in monthList" :key="index" class="calender-month-item">
                        <view v-for="(week, weekindex) in month" :key="weekindex" class="calender-month-week">
                            <!--   :class="{ ischecked: checkedDay == day.date, istoday: day.istoday }" -->
                            <view v-for="(day, dayindex) in week" :class="{ ischecked: checkedDay == day.date }"
                                @click.stop="chooseDay(day)" :key="dayindex" class="calender-month-week-item">
                                <view class="calender-week-day" :class="{
                                    ischecked: checkedDay == day.date,
                                    othermonth: day.othermonth
                                }">
                                    <span class="calender-one-day">
                                        <i class="day">{{
                                            day.othermonth === -1 || day.othermonth === 1
                                            ? ''
                                            : day.day
                                        }}</i>
                                    </span>

                                    <!-- 有事項標(biāo)記 -->
                                    <view class="thing" v-if="day.thing.task_time != null">
                                        <i class="dot"></i>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
            </transition>
        </view>

        <slot></slot>
    </view>
    <!-- 日歷問號提示彈出框 -->
    <w-calender-popup :popupShow="popupShow"></w-calender-popup>
</template>
<script setup lang="ts">
import { ref, onMounted, watch, nextTick } from 'vue'

const props = withDefaults(
    defineProps<{
        isWeek: boolean
        things: Array<any> //日期對應(yīng)的相關(guān)數(shù)據(jù) 數(shù)據(jù)格式 一維數(shù)組
        ispopupShow: boolean
        isMorebtn: boolean
    }>(),
    {
        isWeek: true, // true周 false 月
        ispopupShow: true, // 是否顯示?問號彈窗 默認(rèn)顯示
        isMorebtn: false //是否顯示日歷更多按鈕 默認(rèn)不顯示
    }
)

const emits = defineEmits(['chooseDay', 'toggleMove']) //組件傳遞數(shù)據(jù)
const popupShow = ref<boolean>(false) //是否顯示日歷問號提示
// 打開提示框
const popupShowBtn = () => {
    popupShow.value = !popupShow.value
}

// 頭部星期列表
const WEEK_LIST = [
    {
        text: '日'
    },
    {
        text: '一'
    },
    {
        text: '二'
    },
    {
        text: '三'
    },
    {
        text: '四'
    },
    {
        text: '五'
    },
    {
        text: '六'
    }
]
const dateThing: any = ref([]) //某天事項

// const things: any = ref([]) // 全部事項,用來插入到日歷中
const dispDate = ref<Date>(new Date()) //當(dāng)前時間

type DayType = {
    date?: string | number
    istoday?: boolean
    othermonth?: boolean
    thing?: []
}
type MonthList = DayType[]
const monthList: Record<string, any> = ref<MonthList>([])
const today = ref<Date>(new Date()) //當(dāng)前時間
const MoutnTitle = ref('') //當(dāng)前月份 x-x格式
const checkedDay = ref('') //選中時間
const currentDay = ref<Date>(new Date()) //當(dāng)前時間
const transition = ref<boolean>(true) //是否顯示動畫

const get3FullYear = ref(dispDate.value.getFullYear()) //定義當(dāng)前年
const get3Monthz = ref(dispDate.value.getMonth()) //定義當(dāng)前月
onMounted(() => {
    setTimeout(() => {
        todayDate()
        props.isWeek ? get3week() : get3month(get3FullYear.value, get3Monthz.value)
        initCalenderInfo()
    }, 200)
})
watch(
    () => props.things,
    async () => {
        await nextTick()
        todayDate()
        props.isWeek ? get3week() : get3month(get3FullYear.value, get3Monthz.value)
        initCalenderInfo()
    },
    { immediate: true }
)
const selectDay = ref<Date>(new Date())
/**
 * 轉(zhuǎn)換時間格式
 * @param date 標(biāo)準(zhǔn)時間
 */
const formatDateTime = (date: Date): string => {
    const y = date.getFullYear()
    let m: string = date.getMonth() + 1 + ''
    m = Number(m) < 10 ? '0' + m : m
    let d = date.getDate() + ''
    d = Number(d) < 10 ? '0' + d : d
    return y + '-' + m + '-' + d
}

/**
 * 獲取今天日期
 */
const todayDate = () => {
    checkedDay.value = formatDateTime(today.value)
    selectDay.value = new Date(checkedDay.value)
    MoutnTitle.value = formatDateTime(today.value).substring(0, 7)
}
/**
 * 初始化當(dāng)天事項
 */
const initCalenderInfo = () => {
    const todayThing = monthList.value
        .flat(2)
        .find((item: any) => item.date === checkedDay.value)?.thing
    dateThing.value = todayThing || []
}
/**
 * 返回該天事項
 * @param year 年
 * @param month 月
 * @param day 日
 */
const ifOrder = (year: number, month: number, day: number) => {
    const dateTime = format(year, month, day)
    let dateItem = {}
    props.things.map((item: any) => {
        if (dateTime === item.task_time) {
            dateItem = item
        }
    })
    return dateItem
}

/**
 * 轉(zhuǎn)換時間
 * @param year 年
 * @param month 月
 * @param day 日
 */
const format = (year: number, month: number, day: number | string) => {
    month++
    const m = month < 10 ? '0' + month : month
    Number(day) < 10 && (day = '0' + day)
    return year + '-' + m + '-' + day
}

/**
 * 選中某一天
 * @param year 年
 * @param month 月
 * @param day 日
 * @param othermonth 其他月份,當(dāng)前月前面空值
 * @param mode 類型,'month','week'
 * @param thing 事項
 */
interface chooseDayParams {
    year: number
    month: number
    day: number
    othermonth: number
    mode: string
    thing: Thing[]
}

interface Thing {
    date: string
    infos?: ThingInfo[]
}

interface ThingInfo {
    title: string
    address: string
    dates: string
}

/**
 * @description: 選中日期
 * @param {*} year
 * @param {*} month
 * @param {*} day
 * @param {*} othermonth
 * @param {*} mode
 * @param {*} thing
 * @return {*}
 */
const chooseDay = ({ year, month, day, othermonth, mode, thing }: chooseDayParams): void => {
    currentDay.value = new Date(year, month - 1, day) //標(biāo)準(zhǔn)時間
    checkedDay.value = format(year, month - 1, day) //"2020-11-11"
    if (othermonth && mode === 'month') {
        const tmpDt = new Date(dispDate.value.getFullYear(), dispDate.value.getMonth() - othermonth)
        const maxday = tmpDt.getDate()
        const days = maxday < day ? maxday : day
        dispDate.value = new Date(year, month - othermonth, days)
        changeIndex(othermonth || 0, true)
    } else {
        dispDate.value = currentDay.value
    }
    dateThing.value = thing || []
    emits('chooseDay', checkedDay.value)
}

/**
 * 獲取三周
 */
const get3week = () => {
    const year = dispDate.value.getFullYear()
    const month = dispDate.value.getMonth()
    const day = dispDate.value.getDate()
    monthList.value = []
    monthList.value.push(getWeek(year, month, day - 7))
    monthList.value.push(getWeek(year, month, day))
    monthList.value.push(getWeek(year, month, day + 7))
}

/**
 * 獲取星期
 * @param year 為選中當(dāng)天的年
 * @param month 為選中當(dāng)天的月
 * @param day 為選中當(dāng)天的日
 */
const getWeek = (year: number, month: number, day: number) => {
    const dt = new Date(year, month, day)
    const weekArr = []
    const dtFirst = new Date(year, month, day - ((dt.getDay() + 7) % 7))
    const week = []
    //循環(huán)選中當(dāng)天所在那一周的每一天
    for (let j = 0; j < 7; j++) {
        const newdt = new Date(dtFirst.getFullYear(), dtFirst.getMonth(), dtFirst.getDate() + j)
        const years = newdt.getFullYear()
        const months = newdt.getMonth()
        const days = newdt.getDate()
        const weekItem: weekParams = {
            mode: 'week',
            day: days,
            year: years,
            month: months + 1,
            date: format(years, months, days),
            //日歷要顯示的其他內(nèi)容
            thing: ifOrder(years, months, days),
            istoday:
                today.value.getFullYear() === years &&
                    today.value.getMonth() === months &&
                    today.value.getDate() === days
                    ? true
                    : false,
            ischecked: false,
            othermonth: months !== month
        }
        week.push(weekItem)
    }
    weekArr.push(week)
    return weekArr
}

/**
 * 獲取三個月(上月,本月,下月)
 */
const get3month = (year: any, month: any) => {
    monthList.value = []
    monthList.value.push(getMonth(year, month - 1))
    monthList.value.push(getMonth(year, month))
    monthList.value.push(getMonth(year, month + 1))
}
const MonthType = ref(0) //0 當(dāng)前月 -1上一個月 1下一個月
let Mnum = 1 //計數(shù)
let Ynum = 0

// 點(diǎn)擊上一個月 或者下一個月
const changeMonth = (type: number) => {
    MonthType.value = type
    const date = new Date()
    const year = date.getFullYear()
    const month = date.getMonth()
    let nextYear = year - Ynum
    let chMonth = month + Mnum
    if (type === -1) {
        // 上一個月
        Mnum -= 1
        chMonth = month + Mnum
        Ynum = chMonth <= 0 ? Ynum - 1 : Ynum
        chMonth = chMonth <= 0 ? 12 + chMonth : chMonth
    }
    if (type === 1) {
        // 下一個月
        Mnum += 1
        chMonth = month + Mnum
        Ynum = chMonth > 12 ? Ynum + 1 : Ynum
        chMonth = chMonth > 12 ? chMonth - 12 : chMonth
    }

    nextYear = year + Ynum
    get3FullYear.value = nextYear //修改當(dāng)前年
    get3Monthz.value = chMonth - 1 //修改當(dāng)前月
    get3month(get3FullYear.value, get3Monthz.value)
    const newMonthTitle = `${nextYear}-${chMonth < 10 ? '0' + chMonth : chMonth}`
    MoutnTitle.value = newMonthTitle
}

interface weekParams {
    mode: string
    day: number
    year: number
    month: number
    date: string
    //日歷要顯示的其他內(nèi)容
    thing: ReturnType<typeof ifOrder>
    istoday: boolean
    ischecked: boolean
    othermonth?: number | boolean
}

/**
 * 創(chuàng)建單月歷 順序是從周日到周六
 * @param year 年
 * @param month 月
 */
const getMonth = (year: number, month: number): DayType => {
    const monthArr = [] as any
    const dtFirst = new Date(year, month, 1) // 每個月第一天
    const dtLast = new Date(year, month + 1, 0) // 每個月最后一天
    const monthLength = dtLast.getDate() // 月份天數(shù)
    const firstDayOfWeek = dtFirst.getDay() // 第一天是星期幾
    const rows = Math.ceil((monthLength + firstDayOfWeek) / 7) // 表格顯示行數(shù)
    for (let i = 0; i < rows; i++) {
        const week = []
        for (let j = 0; j < 7; j++) {
            const day = i * 7 + j + 1 - firstDayOfWeek
            if (day > 0 && day <= monthLength) {
                const weekItem: weekParams = {
                    mode: 'month',
                    day: day,
                    year: year,
                    month: month + 1,
                    date: format(year, month, day),
                    // 日歷要顯示的其他內(nèi)容
                    thing: ifOrder(year, month, day),
                    istoday:
                        today.value.getFullYear() === year &&
                            today.value.getMonth() === month &&
                            today.value.getDate() === day
                            ? true
                            : false,
                    ischecked: false,
                    othermonth: 0
                }
                week.push(weekItem)
            } else {
                // 其它月份
                const newDt = new Date(year, month, day)
                const years = newDt.getFullYear()
                const months = newDt.getMonth()
                const days = newDt.getDate()
                const weeksItem: weekParams = {
                    mode: 'month',
                    day: days,
                    year: years,
                    month: months,
                    date: format(year, month, day),
                    thing: ifOrder(year, month, day),
                    istoday:
                        today.value.getFullYear() === years &&
                            today.value.getMonth() === months &&
                            today.value.getDate() === days
                            ? true
                            : false,
                    ischecked: false,
                    othermonth: day <= 0 ? -1 : 1
                }
                week.push(weeksItem)
            }
        }
        monthArr.push(week)
    }
    return monthArr
}
/**
 * 左右移動
 * @param index 月的index
 * @param isWeek 是否顯示周
 * @param isClick 移動不可點(diǎn)擊
 */
const changeIndex = (index: number, isClick = false) => {
    if (props.isWeek) {
        dispDate.value = new Date(
            dispDate.value.getFullYear(),
            dispDate.value.getMonth(),
            dispDate.value.getDate() + 7 * index
        )
        currentDay.value = dispDate.value
        get3week()
    } else {
        const tmpDt = new Date(dispDate.value.getFullYear(), dispDate.value.getMonth() + index, 0)
        const maxday = tmpDt.getDate()
        const days = maxday < dispDate.value.getDate() ? maxday : dispDate.value.getDate()
        dispDate.value = new Date(
            dispDate.value.getFullYear(),
            dispDate.value.getMonth() + index,
            days
        )
        if (!isClick) {
            checkedDay.value = format(
                dispDate.value.getFullYear(),
                dispDate.value.getMonth(),
                dispDate.value.getDate()
            )
        }
        get3month(get3FullYear.value, get3Monthz.value)
    }
    initCalenderInfo()
}

/**
 * 切換月或周
 * @param e event
 */
const toggleMove = () => {
    emits('toggleMove')
}
</script>
<style scoped lang="scss">
.calender {
    &-container {
        width: 100%;
    }

    &-content {
        color: #666666;
    }

    &-title {
        display: flex;

        &-left {
            width: 70%;
        }

        &-right {
            position: absolute;
            right: 60rpx;
            width: 50rpx;
            height: 50rpx;
            border: 1px solid #e51c15;
            color: #e51c15;
            line-height: 44rpx;
            text-align: center;
            border-radius: 50%;
            font-size: 32rpx;
            padding-left: 14rpx;
        }

        &-morebtn {
            border: 2rpx solid #e51c15;
            // padding: 10rpx 40rpx;
            width: 120rpx;
            height: 46rpx;
            line-height: 46rpx;
            text-align: center;
            color: #e51c15;
            box-sizing: border-box;
            font-size: 24rpx;
            margin-right: 20rpx;
            border-radius: 10rpx;
        }

        &-chevronl text,
        &-chevronr text {
            color: #e51c15;
            font-size: 28rpx;
            font-weight: 400;

            &-right {
                text-align: right;
            }
        }

        &-mouth {
            width: 92%;
            text-align: center;
            font-size: 32rpx;
            color: #666666;
        }
    }

    &-week-head {
        width: 100%;
        display: flex;
        align-items: center;
        padding-top: 20px;
        font-size: 24rpx;
        font-weight: bold;

        &-item {
            // width: 14.2%;
            flex: 1;
            text-align: center;
        }
    }

    &-month {
        &-container {
            display: flex;
            position: relative;
            height: 460rpx;
        }

        &-item {
            position: absolute;
            width: 100%;
            min-height: 128rpx;
            padding: 30rpx 0;
            box-sizing: border-box;
        }

        &-item:nth-child(1) {
            left: -110%;
        }

        &-item:nth-child(2) {
            left: 0;
        }

        &-item:nth-child(3) {
            left: 110%;
        }

        &-week {
            display: flex;
            align-items: center;

            &-item {
                // width: 14.2%;
                flex: 1;
                text-align: center;
                position: relative;
            }
        }
    }

    &-week-day {
        display: block;
        text-align: center;
        font-style: normal;
        padding: 2rpx;
        line-height: 60rpx;
        height: 80rpx;
        width: 80rpx;
    }

    &-one-day {
        font-size: 24rpx;
    }
}

.istoday .day,
.ischecked .day {
    width: 60rpx;
    height: 60rpx;
    color: #fff;
    background: #e51c15;
    border-radius: 50%;
    line-height: 60rpx;
    text-align: center;
}

// .ischecked {
//     border-radius: 50px;
//     color: #fff !important;
//     background: #7687e9;
// }
.thing {
    position: absolute;
    left: 34%;
    // bottom: 2px;
    transform: translateX(-50%);
    color: #e51c15;
}

.thing .dot {
    display: block;
    width: 12rpx;
    height: 12rpx;
    word-break: break-all;
    line-height: 12rpx;
    color: #e51c15;
    background: #e51c15;
    border-radius: 50%;
    margin-top: 6rpx;
}
</style>

2. 在頁面引用組件

<template>
<calendar-week-mouth :things="things" @chooseDay.stop="chooseDay" :isMorebtn="true" @toggleMove="toggleMove" ispopupShow :isWeek="isWeek">
</calendar-week-mouth>
</template>

<script setup lang="ts">
import { ref, watch, nextTick, shallowRef } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
onLoad(async (options) => {
    tag.value = Number(options.tag) || 1
    isWeek.value = tag.value === 1 || false
})
const tag = ref(1) //tag 1是周日歷顯示 2是月日歷顯示
const isWeek = ref(true)

/**
 * @description: 點(diǎn)擊單個日期獲取選中的日期
 * @param {*} date:選中的日期 xxxx-xx-xx
 * @return {*}
 */
const chooseDay = (date: string) => {
    checkedDay.value = date
}

// 點(diǎn)擊更多
const toggleMove = () => {
    uni.navigateTo({ url: '/package-legal/task-list/task-list?tag=2' })
}
/**
things數(shù)據(jù)結(jié)構(gòu)
重要的是task_time字段
[{
id: 4,
status: 3,
task_time: "2023-07-26",
task_title: "",
time: "222",
}]
*/
</script>

uniapp 日歷,uni-app,VUE,vue3,uni-app,微信小程序,vue.js

uniapp 日歷,uni-app,VUE,vue3,uni-app,微信小程序,vue.js
uniapp 日歷,uni-app,VUE,vue3,uni-app,微信小程序,vue.js
uniapp 日歷,uni-app,VUE,vue3,uni-app,微信小程序,vue.js文章來源地址http://www.zghlxwxcb.cn/news/detail-758640.html

到了這里,關(guān)于uniapp----微信小程序 日歷組件(周日歷&& 月日歷)【Vue3+ts+uView】的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 使用VS Code創(chuàng)建編寫uniapp項目(vue3+ts 微信小程序)

    使用VS Code創(chuàng)建編寫uniapp項目(vue3+ts 微信小程序)

    uni-create-view :用于快速創(chuàng)建 uni-app 頁面 uni-helper uni-app :代碼提示 uniapp 小程序擴(kuò)展 :鼠標(biāo)懸停查文檔 1.在types屬性中添加屬性名?@types/wechat-miniprogram 和 ?@uni-helper/uni-app-types. 2.添加vueCompilerOptions選項 ①在VS Code中找到設(shè)置 ②在設(shè)置中搜索文件關(guān)聯(lián) ③添加這兩個文件名,值為

    2024年04月27日
    瀏覽(102)
  • uniapp微信小程序安裝uview庫引入組件一直not undefined

    uniapp微信小程序安裝uview庫引入組件一直not undefined

    問題:按照uview官網(wǎng)一步步安裝下載、配置,最后在頁面引入簡單u-button組件,卻顯示 ?按理說一步步照著操作不會存在這種問題,檢查uview-ui文件確實(shí)是在node-modules下面 沒毛病?。。≡诰W(wǎng)上翻閱很多文章, 發(fā)現(xiàn)是uview官網(wǎng)配置最后一步的問題 4. 配置easycom組件模式 此配置需要

    2024年01月22日
    瀏覽(104)
  • uniapp+vue3+ts--編寫微信小程序?qū)觘簽寶簽署時跳轉(zhuǎn)刷臉效果(人臉識別)中間頁代碼

    uniapp+vue3+ts--編寫微信小程序?qū)觘簽寶簽署時跳轉(zhuǎn)刷臉效果(人臉識別)中間頁代碼

    e簽寶內(nèi)嵌H5方式集成簽署頁的文檔說明:https://open.esign.cn/doc/opendoc/case3/ahb0sg 簽署時跳轉(zhuǎn)刷臉效果示意圖: 1. 在文件夾新建一個文件,路徑為pages/middle/index,并在pages.json中注冊?!緋s這個路徑要跟e簽寶后臺定義的中間頁路徑一致】 2.通過上面文檔步驟進(jìn)行相關(guān)代碼編寫,下面

    2024年01月25日
    瀏覽(110)
  • uniapp vue3版本+ts使用 vant小程序 組件庫

    1.首先從uniapp官網(wǎng)下載vue3版本+ts的模板 2.安裝vant微信小程序版本 3.在項目src目錄創(chuàng)建wxcomponents文件夾,在wxcomponents文件夾下創(chuàng)建vant文件夾 4.從node_modules文件夾下的@vant文件夾里面的weapp,weapp下的dist文件夾,將dist文件夾里面的文件復(fù)制到/wxcomponents/vant 5.全局引用? ?在 pages

    2024年02月13日
    瀏覽(101)
  • uniapp 微信小程序使用uview u-tabbar組件自定義tabbar

    uniapp 微信小程序使用uview u-tabbar組件自定義tabbar

    1.在components文件下面新建TabBar.vue組件, 使用uview的u-tabbar組件進(jìn)行二次封裝; u-tabbar組件中value取當(dāng)前匹配項的name, 一般從父組件傳過來即可; 在u-tabbar-item標(biāo)簽內(nèi)可以使用插槽?slot=\\\'inactive-icon\\\'(選中的圖標(biāo))和slot=\\\'inactive-icon\\\'(未選中的圖標(biāo))自定義圖片樣式 u-tabbar組件默認(rèn)已經(jīng)為i

    2024年02月13日
    瀏覽(95)
  • uniapp中使用uview組件u-icon 編輯到微信小程序樣式問題

    在微信小程序中用u-icon標(biāo)簽選擇器才能對其設(shè)置樣式,但在h5預(yù)覽中u-icon{ }這樣設(shè)置樣式不生效,用組件的customStyle屬性才生效。所以干脆對不同平臺用不同寫法: 同時在style標(biāo)簽里使用u-icon選擇器寫樣式來作用于微信小程序中: 這樣互不影響

    2024年02月16日
    瀏覽(144)
  • 微信小程序/vue3/uview-plus form兜底校驗(yàn)

    微信小程序/vue3/uview-plus form兜底校驗(yàn)

    1. :model=‘form’ 若把form的值設(shè)置為 空對象? const form = reactive({? }); 控制臺報錯? ? 2.?不能把 prop 寫為name 否則沒有任何效果

    2024年02月07日
    瀏覽(34)
  • uniapp 給自定義組件或uview等ui組件加class樣式或修改樣式在微信小程序不生效的情況

    uniapp 給自定義組件或uview等ui組件加class樣式或修改樣式在微信小程序不生效的情況

    首先不論是自定義組件還是ui組件,本質(zhì)上的原因都是微信小程序默認(rèn)的組件隔離策略導(dǎo)致的。 微信小程序組件隔離文檔參考 1.在原有class上修改樣式 比如我在uview radio 單選組件的原有class(.u-radio ) ,修改樣式出現(xiàn)不生效的情況 解決: 加上 ::v-deep 即可 2.增加class 比如我在

    2024年02月02日
    瀏覽(98)
  • 【vue3】uniapp 微信小程序 打包優(yōu)化【超詳細(xì)】

    【vue3】uniapp 微信小程序 打包優(yōu)化【超詳細(xì)】

    使用HBuilder編輯器編譯uniapp的項目轉(zhuǎn)為微信小程序,并上傳發(fā)布項目 微信小程序官網(wǎng)限制發(fā)布的主包大小不能超過2mb,我的項目編譯后大小為3mb 1.vendor.js文件過大,打包的時候并沒有設(shè)置為mini版 2.項目的主包太大,并沒有分包出去(后面會詳細(xì)說明如何分包) 1.把微信小程序右

    2024年02月09日
    瀏覽(178)
  • 微信小程序使用uView組件庫

    微信小程序使用uView組件庫

    在公司做的一個項目是微信小程序,因?yàn)樾〕绦虻膗i圖樣式很簡單,所以一開始是打算自己寫的,但是后面發(fā)現(xiàn)有一些功能實(shí)現(xiàn)起來很冗雜,所以最終選擇了使用微信小程序的ui組件庫。 一開始是使用的是VantUi,但是不知道為什么在我的小程序里面跑不起來,所以后來選擇使

    2024年01月19日
    瀏覽(90)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包