Giter VIP home page Giter VIP logo

Comments (6)

haoziqaq avatar haoziqaq commented on August 23, 2024

没能复现这个问题,需要提供一下最小化的可复现 demo。

from varlet.

wthvosk avatar wthvosk commented on August 23, 2024

找到问题了,是表单内传给input的验证规则引起的

<var-input
                        v-model="model.username"
                        :placeholder="$t('page.login.common.userNamePlaceholder')"
                        :rules="new Rules().required().value"
                        size="small"
                        variant="outlined"
                    >
                        <template #prepend-icon>
                            <var-icon name="account-circle"/>
                        </template>
                    </var-input>
export class Rules {
    rules = []

    get value() {
        return this.rules;
    }

    required(errorMessage = '不能为空') {
        this.rules.push((v) => {
            if (v === null || v === undefined) return errorMessage;
            if (typeof v === 'string' && v.trim() === '') return errorMessage;
            if (Array.isArray(v) && v.length === 0) return errorMessage;
            if (typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length === 0) return errorMessage;
            return true;
        });
        return this;
    }
}

from varlet.

haoziqaq avatar haoziqaq commented on August 23, 2024

from varlet.

wthvosk avatar wthvosk commented on August 23, 2024

午休了,下午整一个

from varlet.

wthvosk avatar wthvosk commented on August 23, 2024

抱歉,水平有限,起新项目实在是复现不出来,总而言之换了种导出方式后问题解决了(还是一样,开发时正常,生产环境才出问题),可能是打包时类名压缩啥的出的问题,所以新项目不会出现。

class formRules{
    rules = []

    get value() {
        return this.rules;
    }

    required(errorMessage = '不能为空') {
        this.rules.push((v) => {
            if (v === null || v === undefined) return errorMessage;
            if (typeof v === 'string' && v.trim() === '') return errorMessage;
            if (Array.isArray(v) && v.length === 0) return errorMessage;
            if (typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length === 0) return errorMessage;
            return true;
        });
        return this;
    }
}

export const Rules = new formRules();
<var-form ref="formRef">
        <var-space
            direction="column"
            size="5vmin"
        >
            <var-input
                v-model="model.username"
                :placeholder="$t('page.login.common.userNamePlaceholder')"
                :rules="Rules.required().value"
                size="small"
                variant="outlined"
                @keydown.enter="handleSubmit"
            >
                <template #prepend-icon>
                    <var-icon name="account-circle"/>
                </template>
            </var-input>
<var-input
                v-model="model.password"
                :placeholder="$t('page.login.common.passwordPlaceholder')"
                :rules="Rules.required().value"
                size="small"
                type="password"
                variant="outlined"
                @keydown.enter="handleSubmit"
            >
                <template #prepend-icon>
                    <var-icon name="lock"/>
                </template>
            </var-input>
</var-space>
</var-form>

from varlet.

haoziqaq avatar haoziqaq commented on August 23, 2024

这种现象很像是构建触发了 tree-shaking 导致部分代码被摇掉了。这个 issue 暂时开启一段时间,有问题可以留在这边。

from varlet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.