This commit is contained in:
3056762376@qq.com 2022-11-12 15:09:20 +08:00
parent 170de984d5
commit c9724f0f79
6 changed files with 104 additions and 1 deletions

View File

@ -9,7 +9,6 @@
<body>
<div id="app">
<apps>
<div slot-scope="item">
<h1>这是父组件</h1>
<span v-for="li in item">

View File

@ -0,0 +1,67 @@
<!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>Document</title>
</head>
<!--
插槽如果不是具名插槽,那么插槽内的内容就会被引用内的内容进行替换
-->
<body>
<div id="app">
<apps>
<div slot-scope="datas" slot="ul_list">
<h1>这是修改后的内容</h1>
<div v-for="item,index,key in datas">
<p>{{item[key].name}}</p>
</div>
</div>
</apps>
<br>
<apps></apps>
</div>
<template id="tpl">
<div>
<h1>子组件内容:</h1>
<div>
<slot name="li_list">
<ol>
<li v-for="list in lists">{{list.name}}</li>
</ol>
</slot>
</div>
<div>
<slot name="ul_list" :datas="lists">
<ul>
<li v-for="list in lists">{{list.name}}</li>
</ul>
</slot>
</div>
</div>
</template>
</body>
<script src="../../../JavaScript/vue.js"></script>
<script>
new Vue({
el: "#app",
components: {
'apps': {
template: "#tpl",
data() {
return {
lists: [
{ id: 001, name: "张三", age: 10 },
{ id: 002, name: "李四", age: 22 },
{ id: 003, name: "王五", age: 12 },
]
}
}
}
}
})
</script>
</html>

View File

@ -0,0 +1,10 @@
var name="LiMing"
var sex="男"
let pd = false
function doing(name,sex) {
return `我是${name},我是已经${sex}`
}
export{
pd,doing
}

View File

@ -0,0 +1,2 @@
import { pd,doing } from "./Select_one.js";
console.log(doing('张三','44'));

View File

@ -0,0 +1,10 @@
import { pd,doing } from "./Select_one.js";
function doings(pd){
if (pd == true) {
console.log(`${name}我在做作业`);
} else {
console.log('你好呀');
}
}
console.log(doing("小小", "22"));
console.log(pd);

View File

@ -0,0 +1,15 @@
<!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>Document</title>
</head>
<body>
</body>
<script src="./Select_one.js" type="module"></script>
<script src="./Use_one.js " type="module"></script>
<script src="./Select_two.js" type="module"></script>
</html>