Vue基础入门(下)

news2024/10/6 12:31:27
<script src="https://unpkg.com/vue@next"></script>

mixin混入(局部使用)

定义mixin对象 

<script>
    // mixin 混入
    const mymixin={
        data(){
            return {
                number:2,
                count:1
            }
        },
        created(){
            console.log('mymixin created');
        },
        methods:{
            handleClick(){
                console.log('mymixin click');
            }
        }
    };

    const app = Vue.createApp({
        data() {
            return {
                number: 1
            }
        },
        mixins:[mymixin],
        created(){
            console.log('created');
        },
        methods: {
            handleClick() {
                console.log('handleClick');
            },

        },
        template: `
            <div>
                <div>{{number}}</div>
                <div>{{count}}</div>
                <button @click="handleClick">增加</button>
            </div> 
        `
    });

    const vm = app.mount('#root');
</script>

说明:组件data,methods优先级高于mixin中data,methods优先级,而生命周期函数先执行mixin里面的,再执行组件里面的

mixin混入(全局使用)

const app = Vue.createApp({
        data() {
            return {
                number: 1
            }
        },
        created(){
            console.log('created');
        },
        methods: {
            handleClick() {
                console.log('handleClick');
            },

        },
        template: `
            <div>
                <div>{{number}}</div>
                <child />
                <button @click="handleClick">增加</button>
            </div> 
        `
    });

    app.mixin({
        data(){
            return{
                number:2,
                count:1
            }
        },
        created(){
            console.log('mymixin created');
        },
        methods:{
            handleClick(){
                console.log('mymixin click');
            }
        }
    })

    app.component('child',{
        template:"<div>{{count}}</div>"
    });

    

    const vm = app.mount('#root');

显示自定义属性

默认情况下,组件的属性优先级高于mixin的属性优先级,想要修改的话,必须补充配置合并策略

// mixin 混入
    const mymixin = {
        number: 1
    };

    const app = Vue.createApp({
        mixins:[mymixin],
        number: 2,
        template: `
            <div>
                <div>{{this.$options.number}}</div>
            </div> 
        `
    });

    app.config.optionMergeStrategies.number=(mixinVal,appValue)=>{
        return mixinVal||appValue;
    }
    const vm = app.mount('#root');

自定义指令(局部和全局)

// 自定义指令 directive

    // 局部指令
    // const directives={
    //     focus:{
    //         mounted(el){
    //             el.focus();
    //         }
    //     }
    // }

    const app=Vue.createApp({
        data(){
            return{
                hello:true
            }
        },
        // directives:directives,
        template:`
            <div>
                <div v-show="hello"><input v-focus /></div>    
            </div>
          `
    })

    // 全局指令
    app.directive('focus',{
        beforeMount(el){
            console.log('beforeMount');
        },
        mounted(el){
            el.focus();
            console.log('mounted');
        },
        // 变化前执行 v-show
        beforeUpdate(){
            console.log('beforeUpdate');
        },
        updated(){
            console.log('updated');
        },
        // 销毁前执行 v-if
        beforeUnmount(){
            console.log('beforeUnmount');
        },
        unmounted(){
            console.log('unmounted');
        }
    });
    const vm = app.mount('#root');

v-pos指令(定位)

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lesson 29</title>
    <style>
        .header{
            position: absolute;
        }
    </style>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="root"></div>
</body>
<script>
    // 自定义指令 directive

    const app=Vue.createApp({
        data(){
            return{
                distance:100
            }
        },
        template:`
            <div>
                <div v-pos:left="distance" class="header"><input /></div>    
            </div>
          `
    })

    // 全局指令
    // app.directive('pos',{
    //     mounted(el,binding){
    //         el.style.top=(binding.value+'px');
    //     },
    //     updated(el,binding){
    //         el.style.top=(binding.value+'px');
    //     }
    // });

    // 当只有mounted和updated且里面内容一样时,可以使用箭头函数
    app.directive('pos',(el,binding)=>{
        console.log(binding);
        el.style[binding.arg]=(binding.value+'px');
    })
    const vm = app.mount('#root');
</script>

</html>

传送门teleport

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lesson 30</title>
    <style>
        .area {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 200px;
            height: 300px;
            background-color: #000;
        }

        .mask {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            top: 0;
            background: #000;
            opacity: 0.5;
            color: #fff;
            font-size: 100px;
        }
    </style>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="root"></div>
    <div id="hello"></div>
</body>
<script>
    // 传送门 teleport

    const app = Vue.createApp({
        data() {
            return {
                show: false,
                message: 'hello'
            }
        },
        methods: {
            handleBtnClick() {
                this.show = !this.show;
            }
        },
        template: `
            <div class="area">
                <button @click="handleBtnClick">按钮</button>
                <teleport to="#hello">
                    <div class="mask" v-show="show">{{message}}</div>    
                </teleport>
            </div>
          `
    })
    const vm = app.mount('#root');
</script>

</html>

slot插槽

const app = Vue.createApp({
        template: `
            <my-title>
                hello
            </my-title>
          `
    });

    app.component('my-title',{
        template:`
        <h1>
            <slot/>
        </h1>  
        `
    })
    const vm = app.mount('#root');

render函数(难底层) 选修课

作用形式:template -> render -> h -> 虚拟DOM(JS对象) -> 真实DOM -> 展示到页面上

// render function

    //加:level="1" 其中1代表数字1,如果不加冒号的话为字符串1
    const app = Vue.createApp({
        template: `
            <my-title :level="1">
                hello jessica
            </my-title>
          `
    });

    app.component('my-title',{
        props:['level'],
        render(){
            const {h}=Vue;
            // 虚拟 DOM
            // {
            //     tagName:'h2',
            //     text:'hello jessica',
            //     attributes:{}

            // }
            return h('h'+this.level,{},this.$slots.default());
        }
    })

    // app.component('my-title',{
    //     props:['level'],
    //     render(){
    //         const {h}=Vue;
    //         return h('h'+this.level,{name: 123123},'hello world');
    //     },
    //     template:`
    //         <h1 name="123123" v-if="level === 1"><slot /></h1>  
    //         <h2 v-if="level === 2"><slot /></h2>  
    //         <h3 v-if="level === 3"><slot /></h3>  
    //     `
    // })

    const vm = app.mount('#root');

 解释:h(标签类型,属性对象,插槽) 它也可以嵌套

h('h'+this.level,{},[this.$slots.default(),h('h4',{},'huhu')])

插件Plugin

// plugin 插件 把通用功能封装起来
    const myPlugin={
        install(app,options){
            console.log(app,options);
            app.provide('name','Dell Lee');
            app.directive('focus',{
                mounted(el){
                    el.focus();
                }
            });
            app.mixin({
                mounted(){
                    console.log('mixin');
                }
            });
            app.config.globalProperties.$sayHello='hello world';
        }
    }
    
    const app = Vue.createApp({
        template: `
            <my-title />
          `
    });

    app.component('my-title',{
        inject:['name'],
        mounted(){
            console.log(this.$sayHello);
        },
        template:`
            <div>{{name}} <input v-focus/></div>
        `
    });

    app.use(myPlugin,{name:'jessica'})
    const vm = app.mount('#root');

mixin打印2次是因为2个组件一旦挂载成功就会执行(注意:先子组件后父组件 mixin里生命周期函数优先级高于组件里优先级(并不会覆盖,只是先后顺序问题)) 

对数据做校验的插件(有bug默认值没有校验) 

const app = Vue.createApp({
        data() {
            return {
                name: 'dell',
                age: 28
            }
        },
        rules: {
            age: {
                validate: age => age > 25,
                message: 'too young,to simple'
            },
            name: {
                validate: name => name.length >= 4,
                message: 'name too short'
            }
        },
        template: `
            <div>name:{{name}},age:{{age}}</div>
          `
    });

    const validatePlugin = (app, options) => {
        app.mixin({
            created() {
                //console.log('mixin ready');//表示当组件初始化差不多结束的时候才执行
                for (let key in this.$options.rules) {
                    const item = this.$options.rules[key];//获取key:age里面的值
                    this.$watch(key, (value) => {
                        const result = item.validate(value);
                        if (!result) console.log(item.message);
                    });
                }
            }
        })
    };

    app.use(validatePlugin);
    const vm = app.mount('#root');

 默认值比如年龄23,没有进行校验,还没想出解决方案

CompositionAPI使用

setup(props,context)作用方式:在实例被完全初始化之前执行的函数

const app = Vue.createApp({
        template: `
            <div @click="handleClick">{{name}}</div>
        `,
        methods:{
            test(){
                console.log(this.$options.setup());
            }
        },
        mounted(){
            this.test();
        },
        // 实例被完全初始化之前执行的函数
        setup(props,context){
            return{
                name:'dell',
                handleClick:()=>{
                    alert(123)
                }
            }
        }
    });

    const vm = app.mount('#root');

解释说明:在setup方法里无法调用外部的方法,模板和生命周期函数,而在外部这些实例的方法或生命周期函数能直接调用setup方法,原因是setup方法执行的时候这个实例并没有被创建并没有完成初始化压根不存在this 拿不到app实例,但是在app实例创建好之后呢 这个setup已经被挂载到app实例上,所以当你有这个实例时候,你在这个实例一定可以获取到setup方法

ref和reactive响应式的引用

原理:通过proxy对数据进行封装,当数据变化时,触发模板等内容的更新

ref处理基础类型的数据,如:字符串,数字(都封装成对象形式,自动调用对象.value显示)

reactive处理非基础类型的数据,如:数组,对象(都封装成原来的样子显示)

Vue在对模板处理的时候会进行转化,当他知道返回的name是一个响应式引用,底层会自动帮我们调用name.value,因此我们只需要写{{name}}就可以显示

const app = Vue.createApp({
        template: `
            <div>{{arr[0]}}</div>
        `,

        //<div>{{name}}</div> 基本类型写法
        //<div>{{nameObj.name}}</div> 对象类型写法

        // 实例被完全初始化之前执行的函数
        // setup(props, context) {
        //     const {ref}=Vue;
        //     // proxy,'dell' 变成 proxy({value:'dell'}) 这样的一个响应式引用
        //     let name = ref('dell');
        //     // 设置延时器
        //     setTimeout(() => {
        //         name.value = 'lee'
        //     }, 2000);
        //     return { name }
        // }

        // setup(props, context) {
        //     const {reactive}=Vue;
        //     // proxy,{name:'zhangsan'} 变成 proxy({name:'zhangsan'}) 这样的一个响应式引用
        //     let nameObj = reactive({name:'zhangsan'});
        //     // 设置延时器
        //     setTimeout(() => {
        //         nameObj.name='lisi'
        //     }, 2000);
        //     return { nameObj }
        // }

        setup(props, context) {
            const { reactive } = Vue;
            let arr = reactive([123]);
            // 设置延时器
            setTimeout(() => {
                arr[0] = 456
            }, 2000);
            return { arr }
        }
    });

    const vm = app.mount('#root');

2s后就变成lisi了

readonly只读不可修改会发生报警

const app = Vue.createApp({
        template: `
        <div>{{nameObj[0]}}</div>
        `,

        setup(props, context) {
            const { reactive,readonly } = Vue;
            let nameObj = reactive([123]);
            let copyNameObj=readonly(nameObj);
            // 设置延时器
            setTimeout(() => {
                nameObj[0] = 456,
                copyNameObj[0]=456
            }, 2000);
            return { nameObj,copyNameObj }
        }
    });

    const vm = app.mount('#root');

toRefs使用

const app = Vue.createApp({
        template: `
        <div>{{name}} {{age}}</div>
        `,

        setup(props, context) {
            const { reactive,readonly,toRefs } = Vue;
            let nameObj = reactive({name:'dell',age:28});
            // 设置延时器
            setTimeout(() => {
                nameObj.name='lee',
                nameObj.age=24
            }, 2000);
            // toRefs proxy({name:'dell',age:28}),
            //{
            // name:proxy({value:'dell'}),
            // age:proxy({value:24})    
            //}
            const {name,age}=toRefs(nameObj);
            return { name,age }
        }
    });

    const vm = app.mount('#root');

记住: 创建reactive对象直接解构的话不能在模板上直接使用的,它不具备响应式,想具备响应式必须调用toRefs做一个转化,再做解构,在模板上就可以响应显示了

toRef使用

如果一个对象上本来没有其属性,但是后面你又想给其添加属性,就可以使用toRef(不建议使用)

// toRef,context
    const app = Vue.createApp({
        template: `
        <div>{{age}}</div>
        `,

        setup(props, context) {
            const { reactive,toRef } = Vue;
            // 推荐注释起来的使用,下面只是为了演示
            // const data=reactive({name:'dell',age:''});
            const data=reactive({name:'dell'});
            const age=toRef(data,'age');
            setTimeout(()=>{
                age.value='28'
            },2000);
            return {age}
        }
    });

    const vm = app.mount('#root');

context使用

emit传统使用

const app = Vue.createApp({
        methods: {
            handleChange() {
                alert('change')
            }
        },
        template: `
            <child @change="handleChange">parent</child>
        `,
    });

    app.component('child', {
        mounted(){
            this.$emit('change');
        },
        setup(props,context){
            const {h}=Vue;
            const {attrs,slots,emit}=context;
            return ()=> h('div',{},slots.default());
        }
    })

    const vm = app.mount('#root');

结果:先弹出窗口,再显示parent

emit使用CompositionAPI

const app = Vue.createApp({
        methods: {
            handleChange() {
                alert('change')
            }
        },
        template: `
            <child @change="handleChange"></child>
        `,
    });

    app.component('child', {
        template:`
            <div @click="handleClick">123123</div>
        `,
        setup(props,context){
            const {attrs,slots,emit}=context;
            function handleClick(){
                emit('change');
            }
            return {handleClick};
        }
    })

    const vm = app.mount('#root');

结果:先显示123123,然后点击弹出窗口

attrs

const app = Vue.createApp({
        template: `
            <child app="app"></child>
        `,
    });

    app.component('child', {
        template:`
            <div>child</div>
        `,
        setup(props,context){
            const {attrs,slots,emit}=context;
            console.log(attrs.app);//app
            return {};
        }
    })

    const vm = app.mount('#root');

slots

const app = Vue.createApp({
        template: `
            <child>parent</child>
        `,
    });

    app.component('child', {
        mounted(){
            console.log(this.$slots);
        },
        setup(props,context){
            const {h}=Vue;
            const {attrs,slots,emit}=context;
            //console.log(slots);
            return ()=>h('div',{},slots.default());
        }
    })

    const vm = app.mount('#root');

实例输入添加到list显示

// 关于list 操作的内容进行了封装
    const listRelativeEffect = () => {
        const { reactive } = Vue;
        const list = reactive([]);
        const addItemToList = (item) => {
            list.push(item);
        }
        return {
            list,
            addItemToList
        }
    }

    // 关于 inputValue 操作的内容进行封装
    const inputRelativeEffect = () => {
        const { ref } = Vue;
        const inputValue = ref('');
        const handleInputValueChange = (e) => {
            inputValue.value = e.target.value;
        }
        return {
            inputValue,
            handleInputValueChange
        };
    }

    const app = Vue.createApp({
        setup() {
            const {list,addItemToList}=listRelativeEffect();
            const {inputValue,handleInputValueChange}=inputRelativeEffect();
            return{
                list,addItemToList,
                inputValue,handleInputValueChange
            }
        },
        template: `
            <div>
                <div>
                    <input :value="inputValue" @input="handleInputValueChange"  />
                    <button @click="addItemToList(inputValue)">提交</button>   
                </div>
                <ul>
                    <li v-for="(item,index) in list" :key="index">{{item}}</li>    
                </ul>    
            </div>
        `
    });

    const vm = app.mount('#root');

computed属性

// computed计算属性
    const app = Vue.createApp({
        setup() {
            const {reactive,computed}=Vue;
            const countObj=reactive({count:0});
            const handleClick=()=>{
                countObj.count+=1;
            };
            let countAddFive=computed({
                get:()=>{
                    return countObj.count+5;
                },
                set:(param)=>{
                    countObj.count=param-5;
                }
            });
            setTimeout(()=>{
                countAddFive.value=100;
            },3000);
            return {countObj,countAddFive,handleClick};
        },
        template: `
            <div>
                <span @click="handleClick">{{countObj.count}}</span> --{{countAddFive}}   
            </div>
        `
    });

    const vm = app.mount('#root');

watch监听 

使用ref时,watch(对象,()=>{}),而使用reactive时,watch([()=>对象],([])=>{}) 注意:当只有一个对象数组可以去掉

// watch 监听
    const app = Vue.createApp({
        setup() {
            const {ref,watch} =Vue;
            const name=ref('dell');
            // 具备一定的惰性 lazy
            // 参数可以拿到原始和当前值
            // 可以侦听多个数据的变化,用一个侦听器承载
            watch(name,(currentValue,prevValue)=>{
                console.log(currentValue,prevValue);
            })
            return {name};
        },
        template: `
        <div>
            <div>
                 Name:<input v-model="name"/>
            </div>
            <div>
                 Name is {{name}}
            </div>
        </div>
            
        `
    });

    const vm = app.mount('#root');

// watch 监听
    const app = Vue.createApp({
        setup() {
            const {reactive,watch,toRefs} =Vue;
            const nameObj=reactive({
                name:'张三',
                englishName:'zhangsan'
            });
            // 具备一定的惰性 lazy
            // 参数可以拿到原始和当前值
            // 可以侦听多个数据的变化,用一个侦听器承载
            watch([()=>nameObj.name,()=>nameObj.englishName],([curName,curEng],[prevName,prevEng])=>{
                console.log('中文名:'+curName,prevName+',英文名:'+curEng,prevEng);
            });
            const {name,englishName}=toRefs(nameObj);
            return {name,englishName};
        },
        template: `
        <div>
            <div>
                 Name:<input v-model="name"/>
            </div>
            <div>
                 Name is {{name}}
            </div>
            <div>
                 engName:<input v-model="englishName"/>
            </div>
            <div>
                engName is {{englishName}}
            </div>
        </div> 
        `
    });

    const vm = app.mount('#root');

 

watchEffect监听器 

// watchEffect 监听
    const app = Vue.createApp({
        setup() {
            const {reactive,watchEffect,toRefs} =Vue;
            const nameObj=reactive({
                name:'张三',
                englishName:'zhangsan'
            });

            // 立即执行,没有惰性
            // 不需要传递你要侦听的内容,自动会感知代码依赖
            // 不需要传递很多参数,只需要一个回调函数
            // 不能获取之前数据的值
            const stop=watchEffect(()=>{
                console.log(nameObj.name);
                console.log(nameObj.englishName);
                setTimeout(()=>{
                    stop();
                },5000);
            });
            const {name,englishName}=toRefs(nameObj);
            return {name,englishName};
        },
        template: `
        <div>
            <div>
                 Name:<input v-model="name"/>
            </div>
            <div>
                 Name is {{name}}
            </div>
            <div>
                 engName:<input v-model="englishName"/>
            </div>
            <div>
                engName is {{englishName}}
            </div>
        </div> 
        `
    });

    const vm = app.mount('#root');

如果你监听的内容没依赖代码的变化,那么该监听器只会立即执行一次,而watch监听器本身是惰性,想要改变也可以,只需要增加第三个参数{immediate:true}

CompositionAPI生命周期函数 

mounted(){}:// dom结构挂载完成之后打印出来

特别注意:CompositionAPI里面没有beforeCreate,created,因为setup()执行时间点在beforeCreate和created两者之间,但是,CompositionAPI却增加了onRenderTracked(页面渲染时,每次都会收集响应式依赖就会自动执行)onRenderTriggered(页面渲染时,每次都会收集响应式依赖第一次渲染不会打印

const app = Vue.createApp({
        // 特别注意:CompositionAPI里面没有beforeCreate,created
        // beforeMount => onBeforeMount
        // mounted => onMounted
        setup() {
            const {
                ref,onBeforeMount,onMounted,onBeforeUpdate,onUpdated,
                onBeforeUnmount,onUnmounted,onRenderTracked,onRenderTriggered
            }=Vue;
            const name=ref('dell');
            onBeforeMount(()=>{
                console.log('onBeforeMount');
            });
            onMounted(()=>{
                console.log('onMounted');
            });
            onBeforeUpdate(()=>{
                console.log('onBeforeUpdate');
            });
            onUpdated(()=>{
                console.log('onUpdated');
            });
            onRenderTracked(()=>{
                console.log('onRenderTracked');
            });
            onRenderTriggered(()=>{
                console.log('onRenderTriggered');
            });
            const handleClick=()=>{
                name.value='lee';
            };
            return {name,handleClick};
        },
        template: `
        <div @click="handleClick">
           {{name}}
        </div> 
        `
    });

    const vm = app.mount('#root');

 

单向数据流(子组件不能改变父组件传递过来的数据)

// 单向数据流
    const app = Vue.createApp({
        setup() {
            const {provide,ref,readonly}=Vue;
            const name=ref('dell')
            provide('name',readonly(name));
            provide('changeName',(value)=>{
                name.value=value;
            })
            return {};
        },
        template: `
        <div>
           <child />
        </div> 
        `
    });

    app.component('child',{
        setup(){
            const {inject}=Vue;
            // inject('name','hello') 给name默认值hello
            const name=inject('name');
            const changeName=inject('changeName');
            const handleClick=()=>{
                // 因为父组件设置了readonly可以有效限制了 子组件进行数据变化
                // name.value='jessica';
                changeName('lee');
            };
            return {name,handleClick};
        },
        template:`
            <div @click="handleClick">{{name}}</div>
        `
    })

    const vm = app.mount('#root');

获取模板dom元素的节点

const app=Vue.createApp({
        setup(){
            const { ref,onMounted }=Vue;
            const hello=ref(null);
            onMounted(()=>{
                console.log(hello.value);
            })
            return {hello};
        },
        template:`
            <div ref="hello">hello world</div>
        `
    });

    const vm = app.mount('#root');

结论:CompositionAPI的语法下,获取真实的DOM元素节点

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/606345.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【Unity3D】Bloom特效

1 Bloom 特效原理 Bloom 特效是指&#xff1a;将画面中较亮的区域向外扩散&#xff0c;造成一种朦脓的效果。实现 Bloom 特效&#xff0c;一般要经过 3 个阶段处理&#xff1a;亮区域检测、高斯模糊、Bloom 合成。 本文完整资源见→Unity3D Bloom 特效。 1&#xff09;亮区域检…

OS-内存管理1- 4种基本管理方式(连续分配,页式,段式,段页)。

一&#xff0c;内存管理四种方式。 二&#xff0c;连续分配管理方式。 连续分配方式&#xff1a;为用户分配连续的内存空间。 1.单一连续分配方式 2.固定分区分配方式 3.动态分区分配方式 4.三种连续分配方式的对比。 三&#xff0c;基于页式存储管理。 1.页式 为进一步提高…

嵌入式系统中I2C总线通信基本方法

将 I2C spec 文章总结为一篇&#xff0c;目录如下 I2C Introduction I2C Architecture I2C Transfer I2C Synchronization And Arbitration I2C Hs-mode1、I2C Introduction 1、I2C 历史 I2C&#xff1a;Inter-Integrated Circuit&#xff0c;集成电路总线。 I2C 是 Philips…

部分网络结构记录

CVPR 2022 | Mobile-Former来了&#xff01;微软提出&#xff1a;MobileNetTransformer轻量化并行网络 文章链接: CVPR 2022 | Mobile-Former来了&#xff01;微软提出&#xff1a;MobileNetTransformer轻量化并行网络 - 知乎 (zhihu.com) Mobile-Former架构图 Mobile-Form…

Mybatis学习笔记一

目录 一、Mybatis特性二、快速入门1.导入依赖2.mybatis-config.xml配置3.创建mapper接口4.创建MyBatis的映射文件5.通过junit测试功能 三、MyBatis获取参数值的两种方式&#xff08;重点&#xff09;1.单个字面量类型的参数2.多个字面量类型的参数3.map集合类型的参数4.实体类类…

【六一特别文章】Python编写一个六一儿童节问答小游戏及趣味比赛

随着六一儿童节的到来&#xff0c;我们可以为孩子们编写一个有趣的小游戏&#xff0c;让他们在游戏中学习有关六一儿童节的知识。本文将介绍如何用Python编写一个六一儿童节问答小游戏及趣味比赛。 首先&#xff0c;我们需要准备一些有关六一儿童节的问题和答案。这里我准备了…

云原生之docker详解

目录 1.云原生概念 1.1 云原生定义 1.2 云原生元素 1.2.1 微服务 1.2.2 DevOps 1.2.3 持续交付 1.2.4 容器化 2. Docker 2.1 Docker概述 2.1.1 Docker 定义 2.1.2 Docker应用场景 2.1.3 Docker的架构 2.2 Docker命令 2.2.1 docker进程相关命令 2.2.2 docker镜像…

htmlCSS-----CSS选择器(下)

目录 前言&#xff1a; 2.高级选择器 &#xff08;1&#xff09;子代选择器 &#xff08;2&#xff09;伪类选择器 &#xff08;3&#xff09;后代选择器 &#xff08;4&#xff09;兄弟选择器 相邻兄弟选择器 通用兄弟选择器 &#xff08;5&#xff09;并集选择器 &am…

测试进阶必备,这5款http接口自动化测试工具真的很香

现在市场上能做接口自动化测试的工具有很多&#xff0c;一搜一大把&#xff0c;让人眼花缭乱。我们去选择对应实现方式时&#xff0c;不管是框架体系还是成熟稳定的工具&#xff0c;核心目的都是期望引入的技术能在最低投入的情况下达到最优效果。 那么我们选择依据出来了&…

LearnOpenGL-高级OpenGL-9.几何着色器

本人初学者&#xff0c;文中定有代码、术语等错误&#xff0c;欢迎指正 文章目录 几何着色器使用几何着色器造几个房子爆破物体法向量可视化 几何着色器 简介 在顶点和片段着色器之间有一个可选的几何着色器几何着色器的输入是一个图元&#xff08;如点或三角形&#xff09;的一…

【02】STM32·HAL库开发-Cortex-M系列介绍 | Cortex内核分类及特征 | Cortex-M3/M4/M7介绍

目录 1.ARM公司&#xff08;了解&#xff09;2.Cortex内核分类及特征&#xff08;了解&#xff09;3.Cortex-M3/4/7介绍&#xff08;了解&#xff09; 1.ARM公司&#xff08;了解&#xff09; ARM的R是RISC&#xff08;精简指令集计算机&#xff09;的缩写。ARM公司只做内核设计…

数学模型在水环境影响评价、防洪评价与排污口论证项目中的应用

数学模型在水环境评价、防洪评价和排污口论证等领域中的重要作用&#xff0c;随着人类活动的不断增加和环境问题的日益突出&#xff0c;对水资源和水环境的保护与管理变得至关重要。为了更好地理解和应对这些挑战&#xff0c;数学模型成为一种强大的工具&#xff0c;能够提供量…

ubuntu22.04使用kk安装kubernates1.20.4和kubesphere3.1.1

注意 存储空间不够可能安装失败 环境 master 192.168.1.108node1 192.168.1.106node2 192.168.1.102 root ssh登录 sudo passwd root sudo apt install openssh-server # 定位 /PermitRootLogin 添加 PermitRootLogin yes # 注释掉#PermitRootLogin prohibit-password #St…

【Jenkins+Ant+Jmeter】持续集成接口测试平台搭建

一、环境准备&#xff1a; 1、JDK&#xff1a;Java Downloads | Oracle 2、Jmeter&#xff1a;Apache JMeter - Download Apache JMeter 3、Ant&#xff1a;Apache Ant - Binary Distributions 4、Jenkins&#xff1a;Jenkins 二、Jemter脚本准备&#xff1a; 1、脚本目录&a…

PyTorch实验—回归任务

PyTorch回归任务 回归任务概述&#xff1a;通过pytorch搭建神经网络&#xff0c;进行气温的预测 回归任务可以看作 y kx b y为需要进行回归预测的值 下面对实验步骤进行整理 导入相关的库 import numpy as np import pandas as pd import matplotlib.pyplot as plt import…

张小飞的Java之路——第四十四章——其他流对象

写在前面&#xff1a; 视频是什么东西&#xff0c;有看文档精彩吗&#xff1f; 视频是什么东西&#xff0c;有看文档速度快吗&#xff1f; 视频是什么东西&#xff0c;有看文档效率高吗&#xff1f; 诸小亮&#xff1a;这一节&#xff0c;我们介绍一下其他不常用的流对象 …

SAP-MM-分割评估-评估类型-评估类别

同一物料的使用&#xff0c;既有“自制品”&#xff0c;又有“外购品”&#xff0c;并且其来源不同&#xff0c;如同一外购品由不同的供应商提供&#xff0c;价格也不相同。也就是说:同一物料有不同的价值指派&#xff0c;即在不同的条件下&#xff0c;同一物料可能有不同的价值…

智能型数字档案馆构建设想

档案作为企业正式权威的数据资源&#xff0c;具有其历史传承和凭证唯一性等特点&#xff0c;随着企业的数字化转型&#xff0c;档案工作更需要数字化转型&#xff0c;档案管理与利用急需借助信息技术手段来管理好和记录好&#xff0c;急需挖掘档案资源&#xff0c;发挥其价值&a…

01.硬盘启动盘,加载操作系统

硬盘启动盘&#xff0c;加载操作系统 模拟硬盘加载操作系统 环境&#xff1a; VMware16 Ubuntu16.04 qemu bochs 2.7 参考: 启动&#xff0c;BIOS&#xff0c;MBR 硬盘控制器主要端口寄存器 《操作系统真相还原》 1.系统开机流程 暂不构建中断向量表&#xff0c;直接加载MBR …

Knowledge Distillation: A Survey

本文是蒸馏学习综述系列的第一篇文章&#xff0c;主要是针对2021年 IJCV Knowledge Distillation: A Survey的一个翻译。 知识蒸馏&#xff1a;综述 摘要1 引言2 知识2.1 基于响应的知识2.2 基于特征的知识2.3 基于关系的知识 3 蒸馏方案3.1 离线蒸馏3.2 在线蒸馏3.3 自蒸馏 4…