首先,如果我不遵守任何 SO 规则,我想道歉,因为这是我的第一个问题。
我想要完成的是在我的页面中有一个方形的gridLayout。该行为应该等同于拥有一个带有stretch="aspectFit"的元素。
如果建议的解决方案可以让我强制执行任何给定的纵横比,而不仅仅是一个正方形,那将是一个不错的加分,因为它可以让我在未来解决多种情况。或者如果它可以应用于任何 Layout 元素,那也很好。
该解决方案可以随心所欲,并且 GridLayout 可以以您需要的任何方式嵌套以完成此任务。
我已经尝试过像这样破解它:
<GridLayout rows="*,auto,*" columns="*,auto,*" backgroundColor="green">
<Image row="1" col="1" src="~/Images/1px-black.png" stretch="aspectFit" width="100%"></Image>
<StackLayout row="1" col="1" orientation="vertical" backgroundColor="lightgray">
<Label text="Label 1" width="100%" height="25%" backgroundColor="red"></Label>
<Label text="Label 2" width="100%" height="25%" backgroundColor="green"></Label>
<Label text="Label 3" width="100%" height="25%" backgroundColor="blue"></Label>
<Label text="Label 4" width="100%" height="25%" backgroundColor="yellow"></Label>
</StackLayout>
</GridLayout>
Run Code Online (Sandbox Code Playgroud)
视觉上它似乎有效,但 GridLayout 的内容没有适当地填充它
PS:我刚刚注意到在我选择的示例中,我试图制作方形的布局元素是嵌套的 StackLayout,但它的想法是相同的。我需要一种方法来使嵌套布局元素平方。
我正在尝试开发一个 nativescript 插件来使用 Azure SDK 执行一些功能。SDK的文档如下所示:
所以我在我的插件中添加了以下功能:
MobileServiceUser.newUser = function (userId, client) {
var userObject = com.microsoft.windowsazure.mobileservices.authentication.MobileServiceUser(userId); // causing the error
client.setCurrentUser(userObject);
};
Run Code Online (Sandbox Code Playgroud)
UserId 是一个字符串。
但是,最上面一行抛出错误:
JS:错误:试图将无效的“this”链接到 Java 对象
我有一个完整的 repo,显示了在Github上创建这个问题的最小实现。
对于如何解决此问题的任何建议,我将不胜感激。
我想从电子邮件中的链接打开我的 android 应用程序。通过 Stackoverflow 搜索,看起来可以使用指向我控制的 url 的 '' 来实现。尽管在使用 Nativescript 构建的 android 应用程序的情况下,我有点困惑如何使用它。只是添加一个我拥有的具有特定数据路径的 url 是唯一需要做的事情吗?在这种情况下,会出现一个应用程序选择器对话框。以这种方式打开应用程序时可以触发某个事件吗?谢谢您的帮助。下面是我需要做的事情的示例。
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
<!-- Custom Path data -->
<data
android:host="www.some.company.com"
android:path="/something"
android:scheme="http"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud) 嗨,我的模板如下所示
<ListView [items]="modules">
<template let-item="item" >
<StackLayout orientation="vertical">
<Switch (checkedChange)="onSwitchModule(item.id,$event)" [checked]="item.active"></Switch>
</StackLayout>
</template>
</ListView>
Run Code Online (Sandbox Code Playgroud)
我的控制器是
ngOnInit() {
this._moduleService.getUserModules()
.subscribe(
response=>{
this.modules = response.data;
}
)
}
onSwitchModule(itemId) {
console.log(itemID); //Gets called on initial true binding on switch checked
}
Run Code Online (Sandbox Code Playgroud)
每次页面加载时 onSwitchModule 都会被调用,item.active 在任何项目上为 true,如何处理?
注意:Nativescript 初学者
我正在使用Nativescript/Angular 2构建应用程序
我希望能够从 URL 下载文件并将其保存到设备中普通用户可以轻松找到它的位置。我相信,下载将是这两个最好的地方iOS和Android。如果我错了,请纠正我。
该文件可以是任何文件类型,而不仅仅是图像。所以主要是spreadsheet,word document,pdf,png,jpg,等。
我在网上和文档中搜索过。该文档描述了一种名为getFile的方法,该方法获取文件并将其保存到您的设备。
我在我的代码中实现了这一点,如下所示:
download (id) {
console.log('Download Started');
getFile("https://raw.githubusercontent.com/NativeScript/NativeScript/master/apps/tests/logo.png").then(function (r) {
console.log(r.path);
}, function (e) {
//// Argument (e) is Error!
});
}
Run Code Online (Sandbox Code Playgroud)
这样做的问题是它将它保存到非用户可访问的位置,例如:
/data/user/0/com.myapp.example/files/logo.png
Run Code Online (Sandbox Code Playgroud)
更新:
我也试过直接指定路径:
fs.knownFolders.documents();
Run Code Online (Sandbox Code Playgroud)
但是,此方法获取用户或外部应用程序无法访问的当前应用程序的文档文件夹
我目前正在开发一个简单的应用程序,该应用程序有一个使用网络视图的 HTML 部分。
内容位于 app/www 文件夹中,我从“home.ts”组件访问它们,在 HTML 中使用类似的内容
<GridLayout
class="main-layout"
columns="*"
rows="*"
>
<WebView
src="~/www/index.html"
class="web-view"
col="0"
id="wv"
row="0"
></WebView>
</GridLayout>
Run Code Online (Sandbox Code Playgroud)
该文件使用了一些图像、一些 JS 和一些 CSS。
它在 Android 上运行良好,但我无法使其在 iOS 上运行。哦,它在 iOS 模拟器上运行良好,但在实际设备中却不行(我目前有一个 iOS 9 iPod touch 来测试这些东西)。
我在 Info.plist 上配置了正确的密钥(它适用于https://www.google.com等 URL ),而且我认为我没有做任何奇怪的事情。
这是我的 package.json
{
"description": "WebView App",
"license": "LicenseRef-LICENSE",
"readme": "README",
"nativescript": {
"id": "com.app.name"
},
"dependencies": {
"@angular/animations": "~4.1.0",
"@angular/common": "~4.1.0",
"@angular/compiler": "~4.1.0",
"@angular/core": "~4.1.0",
"@angular/forms": "~4.1.0",
"@angular/http": "~4.1.0",
"@angular/platform-browser": "~4.1.0",
"@angular/router": "~4.1.0",
"nativescript-angular": "~3.0.0",
"nativescript-theme-core": …Run Code Online (Sandbox Code Playgroud) 我正在做一个 Nativescript-Angular-App,但遇到了问题。
用户必须单击图片上的正确位置。
我不明白如何获取简单点击的坐标。
我可以通过触摸手势(TouchGestureEventData)获取坐标,但它提供了信息流。我只想要一个数据。
我尝试过触摸:
public onTouch(args: TouchGestureEventData) {
console.log(args.getActivePointers()[0].getX());
}
Run Code Online (Sandbox Code Playgroud)
但我得到了太多的数据(每个动作)。
有没有一种方法可以通过简单的点击来获取坐标?
谢谢!
当我尝试以下操作时:
const routes: Routes = [
{
path: "", component: RegisteredLayoutComponent, canActivate: [AuthGuard], children: [
{
path: '',
redirectTo:
"/(topicsTab:topicsPage//newsTab:newsPage//homeTab:homePage//askTab:askPage//moreTab:morePage)",
pathMatch: "full"
},
{ path: 'home', component: HomePageComponent, outlet: "homeTab" },...
{ path: '**', redirectTo: '' }
Run Code Online (Sandbox Code Playgroud)
我收到“错误:无法匹配任何路由。URL 段”
难道我做错了什么?包含路由器插座的页面如下所示:
<BottomNavigation selectedIndex="2">
<TabStrip backgroundColor="white">
<TabStripItem>
<Label text="Topics" class="icon__color"></Label>
<Image src="~/assets/round_people_black_18dp.png" class="fas t-36 icon__color"></Image>
</TabStripItem>
<TabStripItem class="special">
<Label text="News" class="icon__color"></Label>
<Image src="~/assets/round_local_library_black_18dp.png" class="fas t-36 icon__color"></Image>
</TabStripItem>
<TabStripItem class="special">
<Label text="Home" class="icon__color"></Label>
<Image src="~/assets/round_home_black_18dp.png" class="fas t-36 icon__color"></Image>
</TabStripItem>
<TabStripItem class="special">
<Label text="Ask?" …Run Code Online (Sandbox Code Playgroud) 每当我单击 window 的 nativeScript sidekick 下载链接时,它都会将我重定向到主页。我在那里没有看到 nativescript 助手的任何下载链接。所以我寻找关于sidekick是否停产的信息,但我什么也没找到。如果有人有 nativescript 助手的下载链接或有关停止使用的信息,请分享谢谢
我正在开发一个 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 ×10
angular ×3
android ×2
javascript ×2
typescript ×2
aspect-fit ×1
aspect-ratio ×1
azure ×1
grid-layout ×1
http ×1
ios ×1
local-files ×1
vue.js ×1
vuex ×1
webview ×1