小编JaS*_*Hin的帖子

打字稿 - 可选类型

如何在 Typescript 中使用可选类型?例如,我有一个名为的对象Conversation

class Conversation {
    lastMessage?: Message
}

class Message {
    text: string
}
Run Code Online (Sandbox Code Playgroud)

我想通过对象textMessage对象获得可为空Conversation

const lastMessageText?: string = conversation?.lastMessage.text
Run Code Online (Sandbox Code Playgroud)

但这种语法不起作用。?谈话后我无法写作。

typescript

8
推荐指数
2
解决办法
8702
查看次数

如何将JS库导入React Native项目中的typescript

如何将js库(在我的情况下是xhook库)导入到用typescript编写的react本机项目中?或者我如何为外部js库创建typescript头文件?

javascript typescript react-native

7
推荐指数
2
解决办法
2403
查看次数

Metro bundler - 日志/详细

如何打开详细模块或地铁捆绑器的日志在哪里?它总是卡住,我不知道为什么。我在 KotlinJS 中使用默认的 React Native 项目。

javascript react-native

6
推荐指数
0
解决办法
469
查看次数

RequestPurchaseAsync() 之后立即 StorePurchaseStatus.NotPurchased

在我通过 Desktop Bridge 打包的 WPF 应用程序中,我发现了一个问题,即某些用户无法通过应用内购买购买插件。它显示我的“已取消”警报,该警报代表的StorePurchaseStatus.NotPurchased位置。result.ExtendedErrornull

目标框架是:

<TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
Run Code Online (Sandbox Code Playgroud)

以下是促成购买的简化代码:

namespace MyApp {


    public partial class MainWindow: Window {
        private readonly StoreContext context;


         public MainWindow(){
            context = StoreContext.GetDefault();
         }
    

        private bool IsAdministrator()
        {
            var identity = WindowsIdentity.GetCurrent();
            var principal = new WindowsPrincipal(identity);
            return principal.IsInRole(WindowsBuiltInRole.Administrator);
        }

        private async void BuyButtonClick(object sender, RoutedEventArgs e) {

            if (IsAdministrator())
            {
                ShowAlert("Cannot run under administrator rights");
                return;
            }


            if (sender is Button button)
            {
                StoreProduct? storeProduct = ((Product)dataContext).storeProduct;

                if (storeProduct != null) …
Run Code Online (Sandbox Code Playgroud)

.net c# uwp desktop-bridge

5
推荐指数
1
解决办法
193
查看次数

无法将变量设置为html元素属性

我发现了一个我不知道如何解决的问题.

如果您使用此模板,那么没有问题:

<li *ngFor="#supplier of supplierList | async">
    <a (click)="changeSupplier($event)">
        <span>{{supplier.id}}: {{supplier.name}}</span>
    </a>
</li>
Run Code Online (Sandbox Code Playgroud)

输出是例如:

<li>
    <a>
        <span>1: Sony</span>
    </a>
</li>
<li>
    <a>
        <span>2: Samsung</span>
    </a>
</li>
Run Code Online (Sandbox Code Playgroud)

如果我编辑模板并尝试将"supplier.id"设置为html属性"data-supplierid":

<li *ngFor="#supplier of supplierList | async">
    <a (click)="changeSupplier($event)" data-supplierid="{{supplier.id}}">
        <span>{{supplier.name}}</span>
    </a>
</li>
Run Code Online (Sandbox Code Playgroud)

出现错误:

Can't bind to 'supplierid' since it isn't a known native property ("i>
                    <li *ngFor="#supplier of supplierList | async">
                        <a (click)="changeSupplier($event)" [ERROR ->]data-supplierid="{{supplier.id}}">
                            <span>{{supplier.name}}</span>
                        </a>
Run Code Online (Sandbox Code Playgroud)

angular

4
推荐指数
1
解决办法
3017
查看次数

如何向现有类添加扩展方法

我想向现有类添加方法扩展,但我不知道如何。我试过这个:

在此处输入图片说明

但我总是收到Property 'addAssembler' doesnt exist on type 'Container'错误。

typescript

3
推荐指数
2
解决办法
4060
查看次数

HackLang by Facebook并不严格

美好的一天,

我有问题.我想在hacklang中模拟一些错误.

<?hh
namespace Exsys\HHVM;

class HHVMFacade{

    private $vector = Vector {1,2,3};

    public function echoProduct() : Vector<string>{
        return $this->vector;
    }

    public function test(Vector<string> $vector) : void{
        var_dump($vector);
    }

}
Run Code Online (Sandbox Code Playgroud)

函数echoProduct()返回字符串的Vector.但私有财产$ vector是整数的向量.当我调用echoFunction并返回值用作函数test()的参数时.我明白了

object(HH\Vector)#35357 (3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) }
Run Code Online (Sandbox Code Playgroud)

为什么?我期待一些错误,因为类型不匹配.

hhvm hacklang

2
推荐指数
1
解决办法
229
查看次数

未定义的符号 av_register_all()

再会,

我是 Objective-C 和 Xcode IDE 的初学者。我正在尝试在我的 iOS 应用程序中使用 ffmpeg。我克隆了https://github.com/kewlbear/FFmpeg-iOS-build-script并为 arm64 和 x86_64 构建。

当我想构建应用程序时它崩溃了

Ld /Users/nikolajpognerebko/Library/Developer/Xcode/DerivedData/CPP3-eowdhpsbeagmxydsrsscofhtuwtl/Build/Products/Debug-iphonesimulator/CPP3.app/CPP3 normal x86_64
cd /Volumes/sedy/xcode/CPP3
export IPHONEOS_DEPLOYMENT_TARGET=9.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.1.sdk -L/Users/nikolajpognerebko/Library/Developer/Xcode/DerivedData/CPP3-eowdhpsbeagmxydsrsscofhtuwtl/Build/Products/Debug-iphonesimulator -L/Volumes/sedy/xcode/CPP3/CPP3/ffmpeg/lib -F/Users/nikolajpognerebko/Library/Developer/Xcode/DerivedData/CPP3-eowdhpsbeagmxydsrsscofhtuwtl/Build/Products/Debug-iphonesimulator -filelist /Users/nikolajpognerebko/Library/Developer/Xcode/DerivedData/CPP3-eowdhpsbeagmxydsrsscofhtuwtl/Build/Intermediates/CPP3.build/Debug-iphonesimulator/CPP3.build/Objects-normal/x86_64/CPP3.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=9.1 -Xlinker -objc_abi_version -Xlinker 2 -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lswresample -lswscale -framework AVFoundation -liconv -lbz2 -Xlinker -dependency_info -Xlinker /Users/nikolajpognerebko/Library/Developer/Xcode/DerivedData/CPP3-eowdhpsbeagmxydsrsscofhtuwtl/Build/Intermediates/CPP3.build/Debug-iphonesimulator/CPP3.build/Objects-normal/x86_64/CPP3_dependency_info.dat -o /Users/nikolajpognerebko/Library/Developer/Xcode/DerivedData/CPP3-eowdhpsbeagmxydsrsscofhtuwtl/Build/Products/Debug-iphonesimulator/CPP3.app/CPP3

Undefined symbols for architecture x86_64:
  "av_register_all()", referenced from:
      Decoder::Decoder() in ViewController.o
ld: symbol(s) not …
Run Code Online (Sandbox Code Playgroud)

xcode ffmpeg objective-c ios

1
推荐指数
1
解决办法
990
查看次数

从 ffmpeg 获取正确的帧速率

再会,

我有个问题。我需要从 ffmpeg 库获得正确的帧速率..

我尝试使用

pFormatCtx->streams[videoStream]->avg_frame_rate.num
Run Code Online (Sandbox Code Playgroud)

avg_frame_rate 的返回值为 2997。但是当我转储元信息时,我得到:

Input #0, avi, from '/test.avi':
  Metadata:
    encoder         : MEncoder SVN-r33883(20110719-gcc4.5.2)
  Duration: 00:49:47.70, start: 0.000000, bitrate: 1294 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 856x480 [SAR 1:1 DAR 107:60], 1090 kb/s, SAR 491520:492521 DAR 8192:4603, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 192 kb/s
2015-09-20 15:47:02.377 TV3[21607:769601] ready to start audio
Run Code Online (Sandbox Code Playgroud)

采样率为:23.98fps。什么值是正确的以及为什么它们不同?

c ffmpeg

1
推荐指数
1
解决办法
3900
查看次数