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>
相关推荐
s9123601011 天前
【Rust】使用lldb 调试core dump
前端·javascript·rust
前端开发呀1 天前
🔥 99%由 Trae AI 开发的 React KeepAlive 组件,竟然如此优雅!✨
前端·trae
不是鱼1 天前
Canvas学习笔记(一)
前端·javascript·canvas
我有一棵树1 天前
React 中 useRef 和 useState 的使用场景区别
前端·javascript·react.js
喵个咪1 天前
Qt6 QML 实现DateTimePicker组件
前端·qt
yinuo1 天前
CSS奇技淫巧:用你意想不到的4种属性实现裁剪遮罩效果
前端
晓翔仔1 天前
网络安全之Web入侵场景
前端·安全·web安全·网络安全·信息安全
想努力找到前端实习的呆呆鸟1 天前
Uniapp如何下载图片到本地相册
前端·vue.js·微信小程序
fmk10231 天前
Vue中的provide与inject
前端·javascript·vue.js
S***H2831 天前
前端性能监控实践,用户体验优化心得
前端·ux