在SuperMap Client项目中的配置
如果你动手能力实在不强,请直接查看参考文件包。
1. 新建vue3项目
cmd
> cd <your-new-project-path>
> npm create vue@latest
...
> npm install
> npm run dev
2. 安装iClient依赖
TIP
上述文档链接中有许多错误,请谨慎辨别
step1
安装leaflet、@supermap/iclient-leaflet
cmd
> npm install @supermap/iclient-leaflet
> npm install leaflet
step2
在main.js
中引入leaflet和iclient leaflet的样式文件
js
import 'leaflet/dist/leaflet.css';
import '@supermap/iclient-leaflet/dist/iclient-leaflet.css';
3.配置Tailwindcss & Element-plus
step1
Tailwindcss参考Install Tailwind CSS with Vite
Element-plus参考使用包管理器安装Element-plus
cmd
> npm install -D tailwindcss postcss autoprefixer
> npx tailwindcss init -p
> npm install element-plus --save
step2
在tailwind.config.js
中增加配置
js
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
step3
在./src/style.css
中增加配置,记得将这个css文件引入到main.js
或 index.html
中
css
import 'element-plus/dist/index.css';
@tailwind base;
@tailwind components;
@tailwind utilities;
TIP
通常vscode都会对@tailwind这个指令标注警告,我们忽略它
step4
在你的App.vue中测试它们:
vue
<script setup >
import {ElButton} from 'element-plus'
</script>
<template>
<div class="shadow-lg bg-blue-100 rounded-3xl w-40 h-40 flex gap-3 flex-col items-center justify-center">
<el-button type="primary">Element-plus</el-button>
<div class="text-purple-600 font-bold">Tailwind CSS</div>
</div>
</template>
<style scoped>
</style>
它预期将渲染为:
Tailwind CSS
如果你发现它没有生效,请检查你是否在main.js
或index.html
中引入了style.css
,然后重启项目:
cmd
> 按住Ctrl + C
> npm run dev
4.配置项目结构
sh
├─assets
│ ├─css
│ ├─font
│ └─styles
├─components
├─composables
│ ├─plugins
├─layouts
├─pages
├─router
├─stores
├─utils
└─views
参考文件包
点击直接下载参考文件包此文件包已经配置好了以下目录,并且包含了后续将用到的几个地图示例
sh
├─.vscode
├─node_modules
├─public
│ └─imgs
└─src
├─assets
│ ├─css
│ └─font
├─components
├─composables
├─pages
├─router
├─stores
├─utils
└─views
使用方式:
解压,进入example目录 npm install npm run dev 浏览器输入
http://localhost:5174