小编Jus*_*wan的帖子

Angular 4无法绑定到<property>,因为它不是<component>的已知属性

我正在尝试在Angular 4中创建自己的指令.但是,当将类的属性绑定到组件模板时,我得到了这个错误.

控制台错误:

Unhandled Promise rejection: Template parse errors: Can't bind to
'data' since it isn't a known property of 'tree'. ("<tree [ERROR
->][data]="data"></tree>"):
Run Code Online (Sandbox Code Playgroud)

我的tree-view-component.ts:

@Component({
    selector: 'app-tree-view',
    template: '<tree [data]="data"></tree>'
})
export class TreeViewComponent implements OnInit {

    @Input() data: any[];

    constructor() {
        this.data = [
        {
            label: 'a1',
            subs: [
                {
                    label: 'a11',
                    subs: [
                        {
                            label: 'a111',
                            subs: [
                                {
                                    label: 'a1111'
                                },
                                {
                                    label: 'a1112'
                                }
                            ]
                        },
                        {
                            label: 'a112'
                        }
                    ]
                },
                {
                    label: 'a12', …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-directives angular

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

如何在Keras中使用训练模型预测输入图像?

我正在使用Keras和tensorflow后端构建CNN模型.我已经训练了模型6个小时.现在,我想使用我的模型预测我的自定义外部图像.如何在Keras做到这一点?谢谢

python deep-learning keras tensorflow

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

ASP.NET 没有适合 WebSocketManagerMiddleware 的构造函数

创建 WebSocketManagerExtensions 时出现错误,如下所示:

System.InvalidOperationException
A suitable constructor for type 
'CustomerManagementCore.WebSocketManager.WebSocketManagerMiddleware' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.
Run Code Online (Sandbox Code Playgroud)

MapWebSocketManager 方法:

public static IApplicationBuilder MapWebSocketManager(this IApplicationBuilder app,
                                                            PathString path,
                                                            WebSocketHandler handler)
{
    return app.Map(path, (_app) => _app.UseMiddleware<WebSocketManagerMiddleware>(handler));
}
Run Code Online (Sandbox Code Playgroud)

WebSocketManagerMiddleware 构造函数:

public WebSocketManagerMiddleware(RequestDelegate next,
                                      WebSocketHandler webSocketHandler)
{
    _next = next;
    _webSocketHandler = webSocketHandler;
}
Run Code Online (Sandbox Code Playgroud)

我知道我的WebSocketManagerMiddleware构造函数是否有问题,但我不知道。有人知道吗?

谢谢。

c# asp.net dnx dnx50 asp.net-core

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

React Navigation:如何使用子堆栈中的特定选项卡返回根选项卡导航器

我在 React Native 中使用react-navigation v2,每当想要返回根导航器中的特定选项卡时都会卡住。

我有以下路线堆栈:

const HomeStack = createStackNavigator(
  {
    Home: Home,
    CreateInvoice: CreateInvoiceScreen,
    InvoiceSummary: InvoiceSummaryScreen,
    PinEntry: PinEntryScreen
  },
  {
    navigationOptions: {
      header: null
    }
  }
);

const CustomersStack = createStackNavigator(
  {
    Customers: CustomersScreen,
    Details: CustomerDetailsScreen
  },
  {
    navigationOptions: {
      header: null
    }
  }
);

const Tab = createBottomTabNavigator(
  {
    Home: HomeStack,
    Transactions: TransactionsTab,
    Customers: CustomersStack,
    Settings: SettingsTab
  }
);

const Routers = createStackNavigator({
  splash: {
    screen: SplashScreen,
    navigationOptions: {...navigationOptions}
  },
  login: {
    screen: LoginScreen, …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-navigation

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

.NET Core JsonDocument.Parse(ReadOnlyMemory&lt;Byte&gt;, JsonReaderOptions) 无法从 WebSocket ReceiveAsync 解析

我使用.NET Core 3.0JsonDocument.Parse(ReadOnlyMemory<Byte>, JsonReaderOptions)将WS消息()解析byte[]为JSON,但它抛出一个异常,如下所示:

'0x00' is invalid after a single JSON value. Expected end of data. LineNumber: 0 | BytePositionInLine: 34.
Run Code Online (Sandbox Code Playgroud)

这是我的中间件片段代码:

WebSocket ws = await context.WebSockets.AcceptWebSocketAsync();
byte[] bytes = new byte[1024 * 4];
ArraySegment<byte> buffer = new ArraySegment<byte>(bytes);

while (ws.State == WebSocketState.Open)
{
       try
       {
             WebSocketReceiveResult request = await ws.ReceiveAsync(bytes, CancellationToken.None);
             switch (request.MessageType)
             {
                     case WebSocketMessageType.Text:
                             string msg = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
                             json = new ReadOnlyMemory<byte>(bytes);
                             JsonDocument jsonDocument = JsonDocument.Parse(json);
                             break;
                     default:
                             break;
             }
       } …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core

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

ASP.NET Core WebSocket 在握手期间失败

我正在尝试使用 ASP.NET Core WebSocket,但new WebSocket("ws://localhost:5702");在 JavaScript 中出现这样的错误:

WebSocket connection to 'ws://localhost:5702/' failed: Error during WebSocket handshake: Unexpected response code: 200
Run Code Online (Sandbox Code Playgroud)

我的配置方法Startup.cs

public void Configure(IApplicationBuilder app)
{
     app.UseDefaultFiles();

     app.UseStaticFiles();

     app.UseWebSockets();
     app.UseWebSocketHandler();
}
Run Code Online (Sandbox Code Playgroud)

我的Middlewares\WebSocketMiddleware.cs
WebSocketMiddleware.cs

有人知道吗?

谢谢你。

.net javascript c# asp.net websocket

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

React Native FlatList的scrollToEnd()不起作用

我想制作一个浮动操作按钮来自动将 FlatList 滚动到底部。我的 FlatList 组件描述如下:

<FlatList
  ref={(ref) => { this.flatListRef = ref; }}
  contentContainerStyle={this.state.barangFiltered.length === 0 && { paddingTop: 10, justifyContent: 'center', alignItems: 'center' }}
  showsVerticalScrollIndicator={false}
  data={this.state.barangFiltered}
  keyExtractor={(item, index) => `barang-${index}`}
  renderItem={({ item, index }) => <Barang
    item={item}
    index={index}
    navigation={this.props.navigation}
    duplicateBarang={(item) => this._duplicateBarang(item)}
    deleteBarang={(item) => this._deleteBarang(item)}
  />}
  ListEmptyComponent={<Text style={{ fontSize: 16, fontWeight: '400' }}>List is empty</Text>}
  getItemLayout={(data, index) => { return {length: 200, index, offset: 200 * index} }}
/>
Run Code Online (Sandbox Code Playgroud)

以及按钮组件:

<TouchableOpacity
  activeOpacity={0.7}
  style={styles.fab}
  onPress={() => this.flatListRef.scrollToEnd()}
>
  <Ionicons name="ios-add" …
Run Code Online (Sandbox Code Playgroud)

javascript android reactjs react-native

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