Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
瓜皮233
Vue-购物车案例
提交
c7b6e727
V
Vue-购物车案例
项目概览
瓜皮233
/
Vue-购物车案例
与 Fork 源项目一致
Fork自
inscode / VueJS
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vue-购物车案例
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
c7b6e727
编写于
4月 29, 2023
作者:
6
642b59b229c89a1824b83ed8
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Auto commit
上级
77948156
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
67 addition
and
17 deletion
+67
-17
package.json
package.json
+1
-0
src/App.vue
src/App.vue
+28
-2
src/assets/base.css
src/assets/base.css
+4
-4
src/assets/main.css
src/assets/main.css
+5
-1
src/components/Goods/Goods.vue
src/components/Goods/Goods.vue
+24
-5
src/components/Header/Header.vue
src/components/Header/Header.vue
+5
-5
未找到文件。
package.json
浏览文件 @
c7b6e727
...
...
@@ -7,6 +7,7 @@
"preview"
:
"vite preview --port 4173"
},
"dependencies"
:
{
"
axios
"
:
"
^1.4.0
"
,
"
guess
"
:
"
^1.0.2
"
,
"
vue
"
:
"
^3.2.37
"
},
...
...
src/App.vue
浏览文件 @
c7b6e727
...
...
@@ -4,16 +4,42 @@
<!-- 页面头部 -->
<Header
title=
"购物车案例"
></Header>
<!-- 页面主体 -->
<h1>
App 根组件
</h1>
<!--
<h1>
App 根组件
</h1>
-->
<!-- 商品列表 -->
<Goods
v-for=
"item in list"
:key=
"item.id"
:title=
"item.goods_name"
:pic=
"item.goods_img"
:chstate=
"item.goods_state"
:id=
"item.id"
></Goods>
</div>
</
template
>
<
script
>
import
axios
from
'
axios
'
import
Header
from
'
@/components/Header/Header.vue
'
import
Goods
from
'
@/components/Goods/Goods.vue
'
export
default
{
components
:
{
Header
,
Goods
,
},
data
()
{
return
{
list
:
[]
}
},
methods
:
{
async
initBuyCars
()
{
// 通过 axios 请求数据
const
{
data
:
res
}
=
await
axios
.
get
(
'
https://www.escook.cn/api/cart
'
)
if
(
res
.
status
===
200
)
{
// 请求成功,将数据赋值给 list
this
.
list
=
res
.
list
}
}
},
created
()
{
// 在实例创建之后请求数据
this
.
initBuyCars
()
}
}
</
script
>
...
...
@@ -21,7 +47,7 @@ export default {
<
style
lang=
"less"
scoped
>
/* 应用程序容器样式 */
.app-container {
padding-top: 45px;
/* 顶部内边距 */
padding-bottom: 50px;
...
...
src/assets/base.css
浏览文件 @
c7b6e727
/* color palette from <https://github.com/vuejs/theme> */
:root
{
/*
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
...
...
@@ -19,10 +19,10 @@
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
}
*/
/* semantic color variables for this project */
:root
{
/*
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
...
...
@@ -71,4 +71,4 @@ body {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
}
*/
src/assets/main.css
浏览文件 @
c7b6e727
@import
"./base.css"
;
/*
@import "./base.css";
#app {
max-width: 1280px;
...
...
@@ -33,3 +33,7 @@ a,
padding: 0 2rem;
}
}
*/
src/components/Goods/Goods.vue
浏览文件 @
c7b6e727
...
...
@@ -4,17 +4,17 @@
<div
class=
"thumb"
>
<div
class=
"custom-control custom-checkbox"
>
<!-- 复选框 -->
<input
type=
"checkbox"
class=
"custom-control-input"
id=
"cb1"
:checked=
"tru
e"
/>
<label
class=
"custom-control-label"
for=
"cb1
"
>
<input
type=
"checkbox"
class=
"custom-control-input"
:id=
"'cb' +id"
:checked=
"chstat
e"
/>
<label
class=
"custom-control-label"
:for=
"'cb' +id
"
>
<!-- 商品的缩略图 -->
<img
src=
"../../assets/logo.png
"
alt=
""
/>
<img
:src=
"pic
"
alt=
""
/>
</label>
</div>
</div>
<!-- 右侧信息区域 -->
<div
class=
"goods-info"
>
<!-- 商品标题 -->
<h6
class=
"goods-title"
>
商品名称商品名称商品名称商品名称
</h6>
<h6
class=
"goods-title"
>
{{
title
}}
</h6>
<div
class=
"goods-info-bottom"
>
<!-- 商品价格 -->
<span
class=
"goods-price"
>
¥0
</span>
...
...
@@ -25,7 +25,26 @@
</
template
>
<
script
>
export
default
{}
export
default
{
props
:{
title
:{
type
:
String
,
default
:
'
商品名称
'
,
},
pic
:{
type
:
String
,
default
:
''
,
},
chstate
:{
type
:
Boolean
,
default
:
true
,
},
id
:{
type
:
Number
,
required
:
true
,
}
}
}
</
script
>
<
style
lang=
"less"
scoped
>
...
...
src/components/Header/Header.vue
浏览文件 @
c7b6e727
<
template
>
<div
class=
"header-container"
>
{{
title
}}
</div>
<div
class=
"header-container"
>
{{
title
}}
</div>
</
template
>
<
script
>
export
default
{
props
:{
title
:{
type
:
String
,
default
:
'
标题
'
,
props
:
{
title
:
{
type
:
String
,
default
:
'
标题
'
,
},
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录