Skip to content

Commit 1974fb4

Browse files
committed
Deps: Support viewport layout & browser prefix
1 parent ea95451 commit 1974fb4

File tree

9 files changed

+579
-13
lines changed

9 files changed

+579
-13
lines changed

.browserslistrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
> 1%
2+
last 2 versions
3+
not dead
4+
chrome > 40
5+
not ie 11

index.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<!DOCTYPE html>
2-
<html lang="zh-cmn-Hans">
2+
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5+
<meta name="theme-color" content="#ffffff" />
6+
<meta name="description" content="The basic Vue3 template for Mobile、PC、IPad, use easy and efficiency." />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover, user-scalable=no"/>
58
<link rel="icon" href="/favicon.ico" />
6-
<meta
7-
name="viewport"
8-
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
9-
/>
109
<title>Vue3 Vant Mobile</title>
1110
</head>
1211
<body>

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue3-vant-mobile",
33
"private": true,
4-
"version": "0.0.0",
4+
"version": "0.2.0",
55
"scripts": {
66
"dev": "vite",
77
"build": "vue-tsc --noEmit && vite build",
@@ -15,6 +15,9 @@
1515
},
1616
"devDependencies": {
1717
"@vitejs/plugin-vue": "^2.3.3",
18+
"less": "^4.1.2",
19+
"postcss-preset-env": "^7.6.0",
20+
"postcss-px-to-viewport": "^1.1.1",
1821
"typescript": "^4.5.4",
1922
"vite": "^2.9.9",
2023
"vite-plugin-style-import": "1.4.1",

postcss.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// postcss.config.js
2+
module.exports = {
3+
plugins: {
4+
'postcss-preset-env': {},
5+
'postcss-px-to-viewport': {
6+
viewportWidth: 375
7+
}
8+
}
9+
}

public/favicon.ico

0 Bytes
Binary file not shown.

src/components/HelloWorld.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const count = ref(0)
77
</script>
88

99
<template>
10-
<h1>{{ msg }}</h1>
10+
<h1 class="title">{{ msg }}</h1>
1111
<van-button type="primary" @click="count++">count is: {{ count }}</van-button>
1212
</template>
1313

@@ -21,6 +21,10 @@ label {
2121
font-weight: bold;
2222
}
2323
24+
.title {
25+
user-select: none;
26+
}
27+
2428
code {
2529
background-color: #eee;
2630
padding: 2px 4px;

src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { createApp } from 'vue'
22
import App from './App.vue'
33
import { createPinia } from 'pinia'
4-
import { Button } from 'vant'
54

65
// Vant 桌面端适配
76
import '@vant/touch-emulator'
8-
7+
import { Button } from 'vant'
98

109
createApp(App)
1110
.use(createPinia())

vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
33
import styleImport, { VantResolve } from 'vite-plugin-style-import'
4+
import pxtoviewport from 'postcss-px-to-viewport'
45

56
// https://vitejs.dev/config/
67
export default defineConfig({

0 commit comments

Comments
 (0)