uni-app:引用文件的方法

绝对定位

①import common from "@/utils/common.js"

②import common from "utils/common.js"

html 复制代码
<template>
	<view>
		
	</view>
</template>
<script>
	import common from "@/utils/common.js"
	export default {
		data() {
			return {
				
			}; 
		},
		methods: {},
		onLoad() {
			console.log(common.generateRandomNumber())
		}
	};
</script>
<style>
	
</style>
html 复制代码
<template>
	<view>
		
	</view>
</template>
<script>
	import common from "utils/common.js"
	export default {
		data() {
			return {
				
			}; 
		},
		methods: {},
		onLoad() {
			console.log(common.generateRandomNumber())
		}
	};
</script>
<style>
	
</style>

相对定位

import common from "../../utils/common.js"

html 复制代码
<template>
	<view>
		
	</view>
</template>
<script>
	import common from "../../utils/common.js"
	export default {
		data() {
			return {
				
			}; 
		},
		methods: {},
		onLoad() {
			console.log(common.generateRandomNumber())
		}
	};
</script>
<style>
	
</style>
相关推荐
e***U8201 小时前
前端路由懒加载实现,React.lazy与Suspense
前端·react.js·前端框架
诸葛亮的芭蕉扇1 小时前
抓图巡检-底图支持绘制
开发语言·前端·javascript
来碗盐焗星球1 小时前
yalc,yyds!
前端
熊猫比分站2 小时前
让电竞数据实时跳动:Spring Boot 后端 + Vue 前端的完美融合实践
前端·vue.js·spring boot
eason_fan2 小时前
ESLint报错无具体信息:大型代码合并中的内存与性能问题排查
前端
ConardLi2 小时前
前端程序员原地失业?全面实测 Gemini 3.0,附三个免费使用方法!
前端·人工智能·后端
木子李BLOG3 小时前
Element Plus
前端·javascript·vue.js
Miketutu3 小时前
【大屏优化秘籍】Element UI El-Table 表格透明化与自定义行样式实战
前端·javascript·vue.js
止水编程 water_proof3 小时前
JavaScript基础
开发语言·javascript·ecmascript
rainboy3 小时前
Flutter :自己动手,封装一个小巧精致的气泡弹窗库
前端·flutter·github