小编Fed*_*ete的帖子

读取“$(...).toast”时出现类型错误

我正在使用 Django Channels 和 WebSockets 编写一个 Web 应用程序,并且我想在 WebSocket 连接打开时动态创建 bootstrap toast ( https://getbootstrap.com/docs/4.2/components/toasts/ )。问题是引发错误“ Uncaught TypeError: $(...).toast is not a function ”。所以问题是如何阅读 $('.toast').toast('show'); Socket.onopen不太喜欢 jQuery)中的行。如果您有任何想法,我将不胜感激?

这是js文件的一部分:

 var Socket = new ReconnectingWebSocket(ws_path)
    Socket.onopen = function (e) {
      newToast();
      $('.toast').toast('show');
     };

    function newToast(data) {
        // create Bootstrap toast element
     };
Run Code Online (Sandbox Code Playgroud)

在html文件的头部,加载了Bootstrap和jQuery:

<head>
   <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
   <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
   <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
Run Code Online (Sandbox Code Playgroud)

PS:我已经尝试用 jQuery 替换美元符号。同样的错误:未捕获的类型错误:jQuery(..) ...

javascript jquery bootstrap-4 django-channels

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

如何在不同文件中拆分 C# 和 HTML 的 Blazor WASM 组件代码?

我有一些 Web 开发的背景,主要是 ASP MVC 和 JavaScript 与 Angular。

目前,我正在学习Blazor WASM,但我有点“困惑”,因为我找不到任何关于如何将以下代码拆分为两个文件的示例。

这是默认模板中一个组件的示例代码:

Counter.razor

@page "/counter"

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
    private int currentCount = 0;

    private void IncrementCount()
    {
        currentCount++;
    }
}
Run Code Online (Sandbox Code Playgroud)

有什么办法可以拆分成 Angular Web 组件吗?.html 和 .ts?在这种情况下 .razor 和 .razor.cs?

Counter.razor - HTML

@page "/counter"

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
Run Code Online (Sandbox Code Playgroud)

Counter.razor.cs - C#

@code {
    private int currentCount = 0;

    private void IncrementCount()
    {
        currentCount++; …
Run Code Online (Sandbox Code Playgroud)

c# razor blazor blazor-client-side

5
推荐指数
2
解决办法
2586
查看次数

如何在 React 应用程序中从 package.json 访问主页?

我创建了一个将由 提供服务的 React 应用程序/example-path。我这样定义它package.json

"homepage":"/example-path"
Run Code Online (Sandbox Code Playgroud)

到目前为止它已经有效,但现在我想添加路由react-router-dom,但它错误地检测/example-path为 URL 的一部分。

这是我的代码:

<Router>
  <Switch>
    <Route path="/product/:id" children={<DisplayProduct />} />
  </Switch>
</Router>
Run Code Online (Sandbox Code Playgroud)

不幸的react-router-dom是尝试匹配完整的 URL /example-path/product/10。如何才能避免这种情况呢?是否可以以homepage某种方式访问​​该变量?


我可以使用<Router basename="/example-path">,但这样的话,这个参数是重复的。我想只在一处定义它。

javascript reactjs react-router react-router-dom

5
推荐指数
2
解决办法
6040
查看次数

窗口未显示 - 获得用户消息平台 (Kotlin) 的同意

我正在尝试使用 Admob 实现 UE 同意,让用户选择是否想要在 Android 中显示个性化广告。我正在通过用户消息平台的“资金选择”来做到这一点。

我已遵守文档中的所有条件。什么都不起作用。

class MainActivity : AppCompatActivity() {
lateinit var bindingClass : ActivityMainBinding

lateinit var consentInformation : ConsentInformation
lateinit var consentForm : ConsentForm


override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    bindingClass = ActivityMainBinding.inflate(layoutInflater)
    setContentView(bindingClass.root)

    val debugSettings = ConsentDebugSettings.Builder(this)
            .setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
            .build()

    val params = ConsentRequestParameters.Builder()
            .setTagForUnderAgeOfConsent(false)
            .setConsentDebugSettings(debugSettings)
            .build()

    consentInformation = UserMessagingPlatform.getConsentInformation(this)
    consentInformation.requestConsentInfoUpdate(
            this,
            params,
            {
                if (consentInformation.isConsentFormAvailable()) {
                    loadForm();
                }
            }
    ) {
        // Handle the error.
    }
}

fun loadForm(){
    UserMessagingPlatform.loadConsentForm(
            this,
            { consentForm …
Run Code Online (Sandbox Code Playgroud)

android admob kotlin android-studio

5
推荐指数
0
解决办法
418
查看次数

如何打开作为子组件的 ng-Bootstrap-Modal?

我是 Angular 的新手,对ng-Bootstrap 的Modals有一些疑问。我已经能够打开同一组件中的模态框,并且它们工作正常,一个例子是:

关联:

<a (click)="openAbout(contentAbout)" class="nav-link">About</a>
Run Code Online (Sandbox Code Playgroud)

点击事件:

  openAbout(contentAbout) {
    this.modalService.open(contentAbout, { centered: true, scrollable: true });
  }
Run Code Online (Sandbox Code Playgroud)

模态:

<ng-template #contentAbout let-c="close" let-d="dismiss">
  <div class="modal-header">
      <h4 class="modal-title" id="modal-primary-title">About us</h4>
      <button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
        <span aria-hidden="true">&times;</span>
      </button>
  </div>
  <div class="modal-body centered">
    <h2>Gravity Now!</h2>
    <p>It is a platform designed for Space Apps Challenge and the Challenge Gravity Map, Earth Watch category and was chosen in the Top 5 of The Most Inspiring Projects of 2014.</p>
    <a …
Run Code Online (Sandbox Code Playgroud)

bootstrap-modal ng-bootstrap angular-components angular ng-bootstrap-modal

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

Xamarin iOS 链接器导致 AutoMapper 问题

我正在开发一个使用 AutoMapper 的 Xamarin 项目。当链接设置为“仅链接框架 SDK”时,初始化地图时出现以下错误

System.ArgumentNullException:值不能为空。参数名称:方​​法

异常并不多,调用堆栈也没有

AutoMapper.Mappers.ConvertMapper.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.ObjectMapperExpression
AutoMapper.Execution.TypeMapPlanBuilder.MapExpression
AutoMapper.Mappers.NullableSourceMapper.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.ObjectMapperExpression
AutoMapper.Execution.TypeMapPlanBuilder.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.MapExpression
AutoMapper .Execution.TypeMapPlanBuilder.CreatePropertyMapFunc
AutoMapper.Execution.TypeMapPlanBuilder.CreatePropertyMapFunc
AutoMapper.Execution.TypeMapPlanBuilder.TryPropertyMap
AutoMapper.Execution.TypeMapPlanBuilder.CreateAssignmentFunc
AutoMapper.Execution.TypeMapPlanBuilder.CreateMapperLambda
AutoMapper.TypeMap.Seal AutoMapper.MapperConfiguration.Seal
AutoMapper.MapperConfiguration..ctor
AutoMapper.MapperConfiguration..ctor AutoMapper.Mapper.Initialize

最初的阅读表明链接器只是从我们正在使用的某个类中删除了一些属性或方法。

但是,在注释掉大部分映射然后一次重新引入一个之后,我发现这个类当前导致了错误。

[Preserve]
internal class ItemBase : CareRecordItemBase
{
      [Preserve]
      public string Topic { get; set; }
    
      [Preserve]
      public string InPractice { get; set; }
    
      [Preserve]
      public string PrivateVal { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

如果我注释掉该InPractice属性,则不会抛出异常。这对我来说毫无意义。谁能解释为什么这可能是一个问题?

是否有更好的方法来诊断这些问题?

automapper xamarin.ios ios xamarin-linker

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

Xamarin Forms - 如何在 POST 方法响应中获取 json 字符串?

我创建了一个列表视图,它根据来自 API“cat_code”的数据显示所有类别,如果您点击其中任何一个,它会将“cat_code”的值传输到变量“selectedItem”中

MenuCategories.xaml

<ListView x:Name="MyCategory" ItemSelected="MyCategory_ItemSelected" >
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell >
                <StackLayout Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center"   >
                    <Label Font="30" HorizontalTextAlignment="Center" x:Name="categoryname" Text="{Binding cat_code}" 
                       Style="{DynamicResource ListItemTextStyle}" />
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud)

MenuCategories.xaml.cs

private string selectedItem;

public MenuCategories()
{
    InitializeComponent();
    GetCategoryAsync();
}

public async Task GetCategoryAsync()
{
    HttpClient client = new HttpClient();
    var response = await client.GetStringAsync("http://ropenrom24-001-site1.etempurl.com/potangina/final/Restserver/index.php/category/view");
    var cat = JsonConvert.DeserializeObject<List<Catergory>>(response);
    MyCategory.ItemsSource = cat;
}

private void MyCategory_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
    var selectedCategory = e.SelectedItem as Catergory;
    if (selectedCategory != null) …
Run Code Online (Sandbox Code Playgroud)

c# post xaml xamarin

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

无法在请求的时间内获得锁定问题

标题是我收到的错误,当我单击“加载”时,我的程序冻结了。我认为这是因为我在声明中执行声明,但从我看来,这是解决我的问题的唯一解决方案。通过加载,我只想重新填充患者列表,但要做到这一点,我还需要了解他们的条件。代码有效,底部方法是我试图修复的。我认为问题是我有 2 份声明未结,但我不确定。加载:

public void DatabaseLoad()
{
    try
    {
        String Name = "Wayne";
        String Pass= "Wayne";
        String Host = "jdbc:derby://localhost:1527/Patients";
        Connection con = DriverManager.getConnection( Host,Name, Pass);
        PatientList.clear();
        
        
        Statement stmt8 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,        
             ResultSet.CONCUR_UPDATABLE);
        String SQL8 = "SELECT * FROM PATIENTS";
        ResultSet rs8 = stmt8.executeQuery( SQL8 );
        ArrayList<PatientCondition> PatientConditions1 = new ArrayList();
        
        while(rs8.next())
        {
            PatientConditions1 = LoadPatientConditions();
        }
        
        Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,    
            ResultSet.CONCUR_UPDATABLE);
        String SQL = "SELECT * FROM PATIENTS";
        ResultSet rs = stmt.executeQuery( SQL );
        
        while(rs.next())
        {
            int id = (rs.getInt("ID")); …
Run Code Online (Sandbox Code Playgroud)

java database netbeans derby

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

Xamarin 中根本没有执行 EvaluateJavascript 或 LoadUrl

我正在尝试将 Activity 中的一些数据共享到 JavaScript,但我所有的结果都失败了,这是我当前的代码:

C#

var webView = FindViewById<WebView>(Resource.Id.webView);

webView.SetWebChromeClient(new WebChromeClient());

webView.Settings.JavaScriptCanOpenWindowsAutomatically = true;
webView.Settings.JavaScriptEnabled = true;
string script = string.Format("javascript:UpdateData('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}');", "1", "2", "3", "4", "5", "6", "7", "8", "9");

webView.LoadUrl("file:///android_asset/index.html");

if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
{
    webView.EvaluateJavascript(script, null);
}
else
{
    webView.LoadUrl(script);
}
Run Code Online (Sandbox Code Playgroud)

index.html 中的JavaScript (我也尝试在头部和正文末尾添加代码):

<script type="text/javascript">
    function UpdateData(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
        alert("Hi");
    }
</script>
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml

<?xml version="1.0" encoding"utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Test.Test" android:versionCode="1" android:versionName="1.0">
    <uses-sdk android:minSdkVersion="19" />
    <application android:label="Test"></application>
  <uses-permission android:name="android.permission.INTERNET" /> …
Run Code Online (Sandbox Code Playgroud)

javascript android webview xamarin.android xamarin

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

奇怪的行为 onCanExecute RelayCommand MVVMLight 5+

我正在将一个工具从 MVVM Light 4.0.3 迁移到 5.4.1,我发现最新的RelayCommand实现有一个非常奇怪的问题。

这是V4.0.3 中的旧实现:

图像1

图像2

这是V5.4.1 中的最新实现:

img4

img3

在我能够使用变量通过以下代码定义canExecute行为(启用按钮)之前:

public ICommand GetNewItemsFromDB { get; private set; }

private bool _IsActive;
public bool IsActive
{
    get
    {
        return _IsActive;
    }
    set
    {
        if (_IsActive != value)
        {
            _IsActive = value;
            this.RaisePropertyChanged(() => IsActive);
        }
    }
}

GetNewItemsFromDB = new RelayCommand(GetDataFromDB, () => { return IsActive == false; });

private void GetDataFromDB()
{
    IsActive = true;
}
Run Code Online (Sandbox Code Playgroud)

之前的代码能够在 MVVM Light 4.0.3 中启用按钮而没有任何问题;然而,在最新的实现中总是被禁用,我添加了一些更改,因为有一个新的 …

c# wpf relaycommand mvvm-light .net-4.5

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

iOS 是否会破坏旋转视图?

我正在考虑在接下来的几个月中构建我的第一个 iOS 应用程序。这是一个混合应用程序:

https://fanmixco.github.io/toastmasters-timer-material-design/

此时已完全迁移到 Android 和 Windows 10。但是,我在 Android 中面临的最大挑战之一是屏幕旋转

这种情况处理起来非常复杂,因为每次我的应用程序旋转时,活动都会被破坏,我需要添加几种解决方法以保持应用程序运行,恢复以前的状态,颜色,在旋转之前停止计时器,因为它们一直在运行在后台

我在 Windows 10 中没有遇到任何类似的情况,我想知道 iOS 视图生命周期的行为是否密切,视图是否在任何设备的旋转过程中被破坏?因为我的解决方法是可重用的,但它们增加了一定的复杂性并降低了性能。

这些是我阅读的一些网站:

尽管如此,我还没有找到任何关于这个主题的确切信息。

聚苯乙烯

  • 我想查找是否有任何文档或示例,因为我在Android 特定情况中投入了大量时间以避免在最后一刻发现我需要重用变通方法。
  • 我不确定这个问题应该在这里还是在软件工程中。如果我应该移动它,请告诉我,我会去做。

android rotation screen-rotation ios hybrid-mobile-app

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

为什么unityengine.ui无法识别?

我有一个问题,我尝试在游戏中创建一个评分系统,玩家根据他行驶的距离获得分数,而 vs 代码无法识别“使用 UnityEngine.ui;” 我已经尝试将 vs code 切换到较低版本(我转到了 1.1.3),但它不起作用。这是我的代码: 在此输入图像描述

unity-game-engine visual-studio-code unity-ui

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