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>
相关推荐
JIngJaneIL5 分钟前
基于Java+ vue智慧医药系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
阿蒙Amon1 小时前
JavaScript学习笔记:6.表达式和运算符
javascript·笔记·学习
hashiqimiya1 小时前
两个步骤,打包war,tomcat使用war包
java·服务器·前端
小a杰.2 小时前
Flutter 设计系统构建指南
开发语言·javascript·ecmascript
零度@2 小时前
Java中Map的多种用法
java·前端·python
yuanyxh2 小时前
静默打印程序实现
前端·react.js·electron
三十_A3 小时前
如何正确实现圆角渐变边框?为什么 border-radius 对 border-image 不生效?
前端·css·css3
kgduu4 小时前
js之事件系统
javascript
小满zs4 小时前
Next.js第十三章(缓存组件)
前端
前端老宋Running4 小时前
“受控组件”的诅咒:为什么你需要 React Hook Form + Zod 来拯救你的键盘?
前端·javascript·react.js