Coder Social home page Coder Social logo

uniapp-starter's Introduction

sn-uniapp-starter

介绍

自定义 uniapp starter,打造自己的uniapp模板项目

特性

  • 基于vuex自定义国际化,支持vue2/vue3,vue/nvue
  • 支持 unplugin-auto-import
  • weex-v-show支持vue2/vue3,参见v-show-view组件
  • 支持pinia,见pinia分支

使用

国际化
1. 基于vuex实现,易扩展,兼容@dcloudio/uni-i18n(即uni-ui也支持国际化)
2. API设计兼容uniapp官方国际化方案
  • 获取当前语言

    • vue2

       this.$i18n.locale
    • vue3

       import { useLang } from '@/hooks/lang.js'
       const { i18n } = useLang()
       i18n.locale
  • 设置语言

    • vue2

       this.$i18n.locale = 'en'
    • vue3

       import { useLang } from '@/hooks/lang.js'
       const { i18n } = useLang()
       i18n.locale = 'en'
  • template中使用

    • 使用前提

      vue3需要导入 @/hooks/lang.js

       <text>{{$t('app.name')}}</text>
  • nvue中使用

    • vue2

       import extendsGlobal from '@/global.js'
       export default extendsGlobal({
       	data() {
       		return {}
       	}
       })
    • vue3

       <script setup>
       	import { useLang } from '@/hooks/lang.js'
       	const { i18n, $t } = useLang()
       	const changeLocale = locale => {
       		i18n.locale = locale
       	}
       </script>

    其次,使用$t('key')

     <text>{{$t('app.name')}}</text>
  • 支持动态切换语言包

    vue2

     this.$i18n.messages = {
     	en: {
     		'app.name': 'test'
     	},
     	'zh-Hans': {
     		'app.name': '测试'
     	},
     	'zh-Hant': {
     		'app.name': '測試'
     	}
     }

    vue3

     i18n.messages = {
     	en: {
     		'app.name': 'test'
     	},
     	'zh-Hans': {
     		'app.name': '测试'
     	},
     	'zh-Hant': {
     		'app.name': '測試'
     	}
     }
组件
v-show-view - 类似v-show指令组件的view
  • vue2

     <v-show-view :show="showTest">
     	<text style="font-size: 50rpx;">weex-show 内容</text>
     </v-show-view>
     export default {
     	data() {
     		return {
     			showTest: true
     		}
     	}
     }
  • vue3

     <v-show-view :show="showTest">
     	<text style="font-size: 50rpx;">weex-show 内容</text>
     </v-show-view>
     <script setup>
     const showTest = ref(true);
     </script>

已知问题

从HBX 3.4.3 Alpha开始,app-nvue已经支持vue3

uniapp-starter's People

Contributors

snice avatar

Stargazers

 avatar Roman avatar  avatar  avatar  avatar

Watchers

 avatar  avatar Kytrun avatar

Forkers

bengban

uniapp-starter's Issues

vue2

v-show这个 nvue里无效 小程序可以 这是为什么

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.