我想用vue js开始一个移动应用程序.任何人都可以建议我可以在vue-native或nativescript-vue之间选择哪个框架?
我有一个带有RadListView组件的nativescript-vue应用程序,用于向用户显示数据。列表的每一行都包含当前项目的多个信息。当我点击一个按钮以加载并显示列表时,UI冻结(快速硬件->短;慢速硬件->长)。我发现加载/合并数据的代码部分运行时间很短,但是UI元素的nativescript内部渲染或创建是问题所在。android控制台显示信息
I/Choreographer: Skipped 430 frames! The application may be doing too much work on its main thread.
Run Code Online (Sandbox Code Playgroud)
我看了stackoverflow和github,但是那里的问题(例如NativeScript Angular RadListView渲染速度非常慢)看起来相似,但是解决方案不适合我。
我使用LinearListView(而不是Grid或Stagged),也许在我的真实应用程序中,我将能够简化列表中的行元素,但在我的示例应用程序中(向下看),我将使用简单的行ui设计。
为了获得更简单,更好的报告,我在{N} -Playground上创建了一个示例应用程序。该应用程序将创建10000个数组元素并将其设置为RadListView的源,其中每个元素都有一个Label,一个Switch和一个ActivityIndicator。
I/Choreographer: Skipped 430 frames! The application may be doing too much work on its main thread.
Run Code Online (Sandbox Code Playgroud)
第一步,将在一个临时数组中生成10000个元素:
loadData() {
this.tmpAlarms = [];
for (let i = 0; i <= 10000; i++) {
this.tmpAlarms.push({
name: "Hase " + i,
active: i % 2 === 0, …Run Code Online (Sandbox Code Playgroud) radlistview nativescript nativescript-telerik-ui nativescript-vue
在我的 nativescript-vue 应用程序中,我有一个名为 profileForm 的单个文件组件。我想以两种方式使用该组件,如果用户登录,我希望将该组件作为布局组件的插槽来编辑配置文件。否则我想要的是作为注册表。
我不想创建额外的组件来处理这个问题。因此,在一种情况下,我希望将组件包装在标签中,以便我可以使用 Vue.$navigateTo 导航到它,在另一种情况下,我希望将其包装在组件中。但该组件本身有一个标签,所以在这种情况下我不再需要它了。
在 django 模板中我会做这样的事情:
<template>
<Page v-if="is_signup" actionBarHidden="true">
<AppLayout v-else title="Profile">
...
</AppLayout v-else>
</Page v-if="is_signup">
</template>
Run Code Online (Sandbox Code Playgroud)
但当然这在 vuejs 中是行不通的。vuejs中有没有办法实现这一点?
我可以创建一个新组件并将其包装在那里,如下所示:
<template>
<Page v-if="is_signup" actionBarHidden="true">
<ProfileForm/>
</Page>
<AppLayout v-else title="Profile">
<ProfileForm/>
</AppLayout>
</template>
Run Code Online (Sandbox Code Playgroud)
但我不想为此任务创建新组件。
我希望得到这样的东西:
<template>
<template :is="is_signup?'Page':'AppLayout'" :v-bind="is_signup?{actionBarHidden:true}:{title:'Profile'}">
...
</template>
</template>
Run Code Online (Sandbox Code Playgroud)
nativescript-vue有这样的语法吗?
我试着添加
<key>UIUserInterfaceStyle</key>
<string>Light</string>
Run Code Online (Sandbox Code Playgroud)
到 App_Resources/iOS/Info.plist
但是该应用程序仍然处于暗模式,即使在重建它并删除钩子、node_modules 和平台之后也是如此。
我正在使用tns preview --bundle.
我正在按照此处说明的指南进行操作:https : //nativescript-vue.org/en/docs/getting-started/vue-devtools/
I have the dev tools and the app up and running but the dev tools says "Waiting for connection..." while the app is already running on my android emulator.
How can I fix this?
我正在尝试在需要API调用的Nativescript-vue后端laravel框架的位置上构建一个小型应用程序,以获取相关数据。例如,如果用户要登录,则需要通过api验证其凭据,oauth/token因此我尝试通过以下axios代码进行调用:
我的settings.js文件包含。
export const authHeader = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
Run Code Online (Sandbox Code Playgroud)
这是在我的axios调用中导入的:
const postData = {
grant_type: 'password',
username: user.email,
password: user.password,
client_id: clientId,
client_secret: clientSecret,
scope: '',
provider: provider
}
const authUser = {}
axios.post(authUrl, postData, {headers: authHeader}).then(response => {
console.log('Inside oauth/token url')
if(response.status === 200)
{
console.log('response received')
}
})
.catch((err) => {
if(err.response.status === 401){
reject('Validation error')
}
else
reject('Something went wrong')
})
Run Code Online (Sandbox Code Playgroud)
当我尝试使用命令进行构建时,tns debug …
我正在使用NativeScript-Vue。
我有一些受保护的页面(仅限会员)。我将用户的登录数据保存在localstorage中。我有两个问题:
当用户打开应用程序时,我们应该在应用程序中的哪个位置编写代码以检索用户的登录数据。我想从本地存储中读取数据并将其填充到Vuex存储中。我知道如何从localstorage读取数据,但是我不知道应该在何时何地进行操作,以便用户可以首先登录。
有几个页面受到保护(仅限成员)。对于这些用户,如果他们已登录(基于vuex存储),我想向他们显示页面内容,但是如果他们未登录,我希望他们导航到登录页面。同样,我对于应该在何处编写此代码/条件感到困惑。
任何帮助表示赞赏。
我曾经运行命令:tns run android --bundle。当我保存更改时,它们会在物理和虚拟 Android 模拟器中自动更新。
现在,当我保存更改时,没有任何反应,必须再次运行命令才能查看更改。
当我保存项目时,出现以下消息:
File change detected. Starting incremental webpack compilation...
Hash: 2e482eb5460af6f4127a
Version: webpack 4.27.1
Time: 1119ms
Built at: 12/04/2019 11:31:32 AM
Asset Size Chunks Chunk Names
a3a53c6e399658f9e1f5.hot-update.json 48 bytes [emitted]
bundle.a3a53c6e399658f9e1f5.hot-update.js 10.1 KiB bundle [emitted] bundle
bundle.js 892 KiB bundle [emitted] bundle
runtime.js 71.4 KiB runtime [emitted] runtime
+ 1 hidden asset
Entrypoint bundle = runtime.js vendor.js bundle.js bundle.a3a53c6e399658f9e1f5.hot-update.js
[../node_modules/nativescript-dev-webpack/style-hot-loader.js!../node_modules/nativescript-dev-webpack/apply-css-loader.js!../node_modules/css-loader/dist/cjs.js?!../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../node_modules/vue-loader/lib/index.js?!./pages/VistaPrueba.vue?vue&type=style&index=0&id=f4390c96&scoped=true&lang=css&] ../node_modules/nativescript-dev-webpack/style-hot-loader.js!../node_modules/nativescript-dev-webpack/apply-css-loader.js!../node_modules/css-loader/dist/cjs.js??ref--1-2!../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../node_modules/vue-loader/lib??vue-loader-options!./pages/VistaPrueba.vue?vue&type=style&index=0&id=f4390c96&scoped=true&lang=css& 1.26 KiB {bundle} [built]
[../node_modules/ts-loader/index.js?!../node_modules/vue-loader/lib/index.js?!./pages/VistaPrueba.vue?vue&type=script&lang=ts&] ../node_modules/ts-loader??ref--4!../node_modules/vue-loader/lib??vue-loader-options!./pages/VistaPrueba.vue?vue&type=script&lang=ts& 1.12 KiB {bundle} [built]
[../node_modules/vue-loader/lib/loaders/templateLoader.js?!../node_modules/vue-loader/lib/index.js?!./pages/VistaPrueba.vue?vue&type=template&id=f4390c96&scoped=true&] …Run Code Online (Sandbox Code Playgroud) 请查看 nativescript-vue 应用程序存储库:
https://github.com/kaanguru/vue-apollo-login
我无法正确解释,所以请查看该应用程序。我不知道如何更新 appolloClient 标头。
应用程序存储库有自己的注释和指令。您可以轻松安装和查看。
Post 请求提交用户的标识符和密码凭据进行身份验证,并在登录页面获取令牌。
Apollo 需要将 jwt 令牌放入 Authorization 标头中。
Main.js:如果有 JWT 以标头开头,则启动 apollo 客户端
如果没有 JWT 则转到登录
如果有智威汤逊,请转到鸟类列表
登录:从服务器获取jwt并将其写入本地存储
import ApolloClient from 'apollo-boost'
import VueApollo from 'vue-apollo'
Vue.use(VueApollo)
const apolloClient = new ApolloClient({
uri: 'http://sebapi.com/graphql',
// HEADERS WORK FINE IF TOKEN WAS IN MAIN
// headers: {
// authorization: `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNTg2MzU2NzM2LCJleHAiOjE1ODg5NDg3MzZ9.wpyhPTWuqxrDgezDXJqIOaAIaocpM8Ehd3BhQUWKK5Q`,
// }
})
const apolloProvider = new VueApollo({
defaultClient: …Run Code Online (Sandbox Code Playgroud) 我正在开发一个 Nativescript-Vue 应用程序,我正在尝试使用 Vuex 从 Timepicker 存储小时和分钟以在其他页面中使用。我试过用计算属性来捕捉事件,但是有没有更好的方法用 Vue 来做到这一点?
这是我所拥有的:
// In NotifyTimePicker.vue (a custom Time-picking modal)
// Template:
<TimePicker row="2" col="0" colSpan="3" horizontalAlignment="center" :hour="selectedFromHour" :minute="selectedFromMinute" />
//Script
computed: {
selectedFromHour: {
get: function () {
return this.$store.state.notifyFromTimeHour
},
set: function (newValue) {
console.log(`Attempting to Update Store with new From Hour = ${newValue}`)
this.$store.commit('changeNotifyFromTimeHour', newValue)
}
},
selectedFromMinute: {
get: function () {
return this.$store.state.notifyFromTimeMinute
},
set: function (newValue) {
console.log(`Attempting to Update Store with new From Minute = ${newValue}`) …Run Code Online (Sandbox Code Playgroud) nativescript-vue ×10
nativescript ×8
vue.js ×6
javascript ×3
vuejs2 ×2
android ×1
axios ×1
graphql ×1
ios ×1
radlistview ×1
vue-apollo ×1
vue-devtools ×1
vue-native ×1
vuex ×1