Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
眼红的小孩
VueJS_676182
提交
c1767a32
V
VueJS_676182
项目概览
眼红的小孩
/
VueJS_676182
与 Fork 源项目一致
Fork自
inscode / VueJS
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VueJS_676182
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
c1767a32
编写于
4月 03, 2025
作者:
Q
qq_63480508
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Thu Apr 3 17:20:00 CST 2025 inscode
上级
aa50c4cb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
128 addition
and
32 deletion
+128
-32
src/App.vue
src/App.vue
+2
-2
src/components/HelloWorld.vue
src/components/HelloWorld.vue
+126
-30
未找到文件。
src/App.vue
浏览文件 @
c1767a32
<
script
setup
>
<
script
setup
>
import
HelloWorld
from
'
./components/HelloWorld.vue
'
import
HelloWorld
from
'
./components/HelloWorld.vue
'
import
TheWelcome
from
'
./components/TheWelcome.vue
'
//
import TheWelcome from './components/TheWelcome.vue'
</
script
>
</
script
>
<
template
>
<
template
>
<header>
<header>
<
img
alt=
"Vue logo"
class=
"logo"
src=
"./assets/logo.svg"
width=
"125"
height=
"125"
/
>
<
!--
<img
alt=
"Vue logo"
class=
"logo"
src=
"./assets/logo.svg"
width=
"125"
height=
"125"
/>
--
>
<div
class=
"wrapper"
>
<div
class=
"wrapper"
>
<HelloWorld
msg=
"You did it!"
/>
<HelloWorld
msg=
"You did it!"
/>
...
...
src/components/HelloWorld.vue
浏览文件 @
c1767a32
<
script
setup
>
defineProps
({
msg
:
{
type
:
String
,
required
:
true
}
})
</
script
>
<
template
>
<
template
>
<div
class=
"greetings"
>
<div
class=
"carousel"
>
<h1
class=
"green"
>
{{
msg
}}
</h1>
<div
class=
"carousel-inner"
:style=
"
{ transform: `translateX(-${currentIndex * 100}%)` }">
<h3>
<div
class=
"carousel-item"
v-for=
"(image, index) in images"
:key=
"index"
>
You’ve successfully created a project with
<img
:src=
"image"
alt=
"轮播图"
/>
<a
target=
"_blank"
href=
"https://vitejs.dev/"
>
Vite
</a>
+
</div>
<a
target=
"_blank"
href=
"https://vuejs.org/"
>
Vue 3
</a>
.
</div>
</h3>
<div
class=
"carousel-controls"
>
<button
@
click=
"prev"
>
‹
</button>
<button
@
click=
"next"
>
›
</button>
</div>
<div
class=
"carousel-indicators"
>
<span
v-for=
"(image, index) in images"
:key=
"index"
:class=
"
{ active: index === currentIndex }"
@click="goTo(index)"
>
</span>
</div>
</div>
</div>
</
template
>
</
template
>
<
script
setup
>
import
{
ref
,
onMounted
,
onUnmounted
}
from
'
vue
'
;
const
images
=
[
'
https://image.so.com/ai/s?q=%E5%B9%B3%E5%8F%B0%E5%9B%BE%E7%89%87&listsrc=sobox&listsign=28c4844d972744afe424ff0172e943a0&src=360pic_strong
'
,
'
https://via.placeholder.com/800x400?text=Slide+2
'
,
'
https://via.placeholder.com/800x400?text=Slide+3
'
,
'
https://via.placeholder.com/800x400?text=Slide+4
'
,
];
const
currentIndex
=
ref
(
0
);
const
intervalTime
=
3000
;
let
timer
=
null
;
const
next
=
()
=>
{
currentIndex
.
value
=
(
currentIndex
.
value
+
1
)
%
images
.
length
;
};
const
prev
=
()
=>
{
currentIndex
.
value
=
(
currentIndex
.
value
-
1
+
images
.
length
)
%
images
.
length
;
};
const
goTo
=
(
index
)
=>
{
currentIndex
.
value
=
index
;
};
onMounted
(()
=>
{
timer
=
setInterval
(()
=>
{
next
();
},
intervalTime
);
});
onUnmounted
(()
=>
{
clearInterval
(
timer
);
});
</
script
>
<
style
scoped
>
<
style
scoped
>
h1
{
.carousel
{
font-weight
:
500
;
position
:
relative
;
font-size
:
2.6rem
;
width
:
800px
;
top
:
-10px
;
height
:
400px
;
overflow
:
hidden
;
margin
:
0
auto
;
border-radius
:
10px
;
box-shadow
:
0
4px
10px
rgba
(
0
,
0
,
0
,
0.1
);
}
.carousel-inner
{
display
:
flex
;
transition
:
transform
0.5s
ease
;
}
.carousel-item
{
min-width
:
100%
;
box-sizing
:
border-box
;
}
.carousel-item
img
{
width
:
220px
;
height
:
220px
;
object-fit
:
cover
;
}
.carousel-controls
{
position
:
absolute
;
top
:
50%
;
width
:
100%
;
display
:
flex
;
justify-content
:
space-between
;
transform
:
translateY
(
-50%
);
}
.carousel-controls
button
{
background
:
rgba
(
0
,
0
,
0
,
0.5
);
border
:
none
;
color
:
#fff
;
font-size
:
2rem
;
padding
:
10px
15px
;
cursor
:
pointer
;
border-radius
:
50%
;
transition
:
background
0.3s
;
}
.carousel-controls
button
:hover
{
background
:
rgba
(
0
,
0
,
0
,
0.7
);
}
}
h3
{
/* 底部指示器 */
font-size
:
1.2rem
;
.carousel-indicators
{
position
:
absolute
;
bottom
:
15px
;
left
:
50%
;
display
:
flex
;
transform
:
translateX
(
-50%
);
}
}
.greetings
h1
,
.carousel-indicators
span
{
.greetings
h3
{
display
:
inline-block
;
text-align
:
center
;
width
:
12px
;
height
:
12px
;
margin
:
0
5px
;
background
:
rgba
(
255
,
255
,
255
,
0.5
);
border-radius
:
50%
;
cursor
:
pointer
;
transition
:
background
0.3s
;
}
}
@media
(
min-width
:
1024px
)
{
.carousel-indicators
span
.active
{
.greetings
h1
,
background
:
rgba
(
255
,
255
,
255
,
1
);
.greetings
h3
{
text-align
:
left
;
}
}
}
</
style
>
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录