Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
984 views
in Technique[技术] by (71.8m points)

blazor server side - Custom Razor component a NuGet library behaves differently?

I created 3 components which have the exact same implementation with only 1 difference:

  • The 1st component (MyTest) is implemented in the same project as its parent component
  • The 2nd one (Component1) is from a different (but same solution)
  • The 3rd (CSInput) is imported from a NuGet package. Below are the invokation of all 3 in the same parent.

The razor component implementation is as followed:

<input disabled="@Disabled">

@code {
 [Parameter]
 public bool Disabled { get; set; }
}

The snippet of the parent implementation:

// The Disabled property is coded as boolean
<MyTest Disabled="@DisableMyTest"/>
<RazorClassLibrary1.Component1 Disabled="@DisableMyTest" />
<CSInput Disabled="@DisableMyTest"/>

@code{
  private bool DisableMyTest = false;
}

For an unknown reason, the compiler issued a CS1503 (cannot convert from 'bool' to 'string') on the Disabled property from CSInput. Any idea why? Many Thanks!

question from:https://stackoverflow.com/questions/65838164/custom-razor-component-a-nuget-library-behaves-differently

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

figured it out. The weird behavior is caused by me not incrementing the version of the nuget. Whenever you install a Nuget, VS keeps a copy of it in the .nugetpackages directory. If you don't clean up that directory, VS will keep use what it has. Now, where can I get wig....


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...