回答編集履歴
6
最終コード修正。htmlタグのimgのurlを修正。
answer
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
画像がリンク切れ表示になってしまうようになりました;
|
4
4
|
今回の質問とは関係ないトラブルなので、また解決できないようでしたら別途質問させて頂きます・・・。
|
5
5
|
|
6
|
+
と思っていたら解決しました。
|
7
|
+
ソート版の方のhtmlタグのimgのurlが間違えていました;
|
8
|
+
文字を一括で置換するさいに、同じ文字で置換してはいけない場所(imgタグのurl部分)も一緒に置換してしまい、
|
9
|
+
それが原因でソート時のみリンク切れが起きているだけでした。
|
10
|
+
大変失礼いたしました。
|
11
|
+
|
6
12
|
```Blazor
|
7
13
|
|
8
14
|
@page "/article001"
|
@@ -20,8 +26,8 @@
|
|
20
26
|
{
|
21
27
|
<li class="builds">
|
22
28
|
<a href="@build.HtmlUrl">
|
23
|
-
<img src="/Images/Builds/@build.
|
29
|
+
<img src="/Images/Builds/@build.ArtImageUrl" style="width:100px; height:auto;
|
24
|
-
|
30
|
+
border:5px #ff0000 solid; margin:10px;" />
|
25
31
|
<span>@build.Number - @build.RegistrationDate</span>
|
26
32
|
<span>@build.Artist - @build.Title</span>
|
27
33
|
<span> @build.Description</span>
|
@@ -36,9 +42,9 @@
|
|
36
42
|
@foreach (var sort in sorts)
|
37
43
|
{
|
38
44
|
{
|
39
|
-
<li class="
|
45
|
+
<li class="builds">
|
40
46
|
<a href="@sort.HtmlUrl">
|
41
|
-
<img src="/Images/
|
47
|
+
<img src="/Images/Builds/@sort.ArtImageUrl" style="width:100px; height:auto;
|
42
48
|
border:5px #ff0000 solid; margin:10px;" />
|
43
49
|
<span>@sort.Number - @sort.RegistrationDate</span>
|
44
50
|
<span>@sort.Artist - @sort.Title</span>
|
@@ -52,25 +58,24 @@
|
|
52
58
|
|
53
59
|
@code {
|
54
60
|
|
55
|
-
public class ArticleItem
|
61
|
+
public class ArticleItem
|
56
62
|
{
|
57
63
|
public int Number { get; set; }
|
58
64
|
public int RegistrationDate { get; set; }
|
59
65
|
public string Artist { get; set; }
|
60
66
|
public string Title { get; set; }
|
61
67
|
public string Description { get; set; }
|
62
|
-
|
63
|
-
public string
|
68
|
+
public string ArtImageUrl { get; set; }
|
64
69
|
public string HtmlUrl { get; set; }
|
65
70
|
|
66
|
-
public ArticleItem(int number, int registrationdate, string artist, string title, string description, string
|
71
|
+
public ArticleItem(int number, int registrationdate, string artist, string title, string description, string artimageurl, string htmlurl)
|
67
72
|
{
|
68
73
|
this.Number = number;
|
69
74
|
this.RegistrationDate = registrationdate;
|
70
75
|
this.Artist = artist;
|
71
76
|
this.Title = title;
|
72
77
|
this.Description = description;
|
73
|
-
this.
|
78
|
+
this.ArtImageUrl = artimageurl;
|
74
79
|
this.HtmlUrl = htmlurl;
|
75
80
|
}
|
76
81
|
}
|
@@ -78,7 +83,7 @@
|
|
78
83
|
List<ArticleItem> sorts;
|
79
84
|
|
80
85
|
List<ArticleItem> builds = new List<ArticleItem>
|
81
|
-
{
|
86
|
+
{
|
82
87
|
new ArticleItem(1, 800, "フェルメール", "真珠の耳飾りの少女", "綺麗系", "vermeer.jpg", "none"),
|
83
88
|
new ArticleItem(2, 1300, "ダ・ヴィンチ", "モナ・リザ", "凄み系", "mona_lisa.jpg", "https://localhost:44391/mona_lisa"),
|
84
89
|
new ArticleItem(3, 1900, "作者不明", "タイトル不明", "謎", "unnamed.jpg", "none"),
|
@@ -103,7 +108,7 @@
|
|
103
108
|
sorts.Sort((a, b) => string.Compare(a.Artist, b.Title));
|
104
109
|
}
|
105
110
|
|
106
|
-
// F5リロード関数 使
|
111
|
+
// F5リロード関数 使用せず。
|
107
112
|
NavigationManager NavigationManager;
|
108
113
|
|
109
114
|
private void HandleClick()
|
@@ -112,6 +117,4 @@
|
|
112
117
|
}
|
113
118
|
}
|
114
119
|
|
115
|
-
|
116
|
-
|
117
120
|
```
|
5
一部些細な箇所を訂正。
answer
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
<h3>Article001</h3>
|
11
11
|
|
12
|
-
<button class="btn btn-primary" @onclick="SortItems">Sort-
|
12
|
+
<button class="btn btn-primary" @onclick="SortItems">Sort-番号昇順</button>
|
13
13
|
<button class="btn btn-primary" @onclick="SortItems2">Sort-西暦降順</button>
|
14
14
|
<button class="btn btn-primary" @onclick="SortItems3">Sort-適当</button>
|
15
15
|
|
4
コードを見やすく修正。
answer
CHANGED
@@ -9,8 +9,6 @@
|
|
9
9
|
|
10
10
|
<h3>Article001</h3>
|
11
11
|
|
12
|
-
|
13
|
-
|
14
12
|
<button class="btn btn-primary" @onclick="SortItems">Sort-名前昇順</button>
|
15
13
|
<button class="btn btn-primary" @onclick="SortItems2">Sort-西暦降順</button>
|
16
14
|
<button class="btn btn-primary" @onclick="SortItems3">Sort-適当</button>
|
@@ -41,7 +39,7 @@
|
|
41
39
|
<li class="sorts">
|
42
40
|
<a href="@sort.HtmlUrl">
|
43
41
|
<img src="/Images/sorts/@sort.ArtImage" style="width:100px; height:auto;
|
44
|
-
|
42
|
+
border:5px #ff0000 solid; margin:10px;" />
|
45
43
|
<span>@sort.Number - @sort.RegistrationDate</span>
|
46
44
|
<span>@sort.Artist - @sort.Title</span>
|
47
45
|
<span> @sort.Description</span>
|
@@ -54,6 +52,29 @@
|
|
54
52
|
|
55
53
|
@code {
|
56
54
|
|
55
|
+
public class ArticleItem
|
56
|
+
{
|
57
|
+
public int Number { get; set; }
|
58
|
+
public int RegistrationDate { get; set; }
|
59
|
+
public string Artist { get; set; }
|
60
|
+
public string Title { get; set; }
|
61
|
+
public string Description { get; set; }
|
62
|
+
|
63
|
+
public string ArtImage { get; set; }
|
64
|
+
public string HtmlUrl { get; set; }
|
65
|
+
|
66
|
+
public ArticleItem(int number, int registrationdate, string artist, string title, string description, string artimage, string htmlurl)
|
67
|
+
{
|
68
|
+
this.Number = number;
|
69
|
+
this.RegistrationDate = registrationdate;
|
70
|
+
this.Artist = artist;
|
71
|
+
this.Title = title;
|
72
|
+
this.Description = description;
|
73
|
+
this.ArtImage = artimage;
|
74
|
+
this.HtmlUrl = htmlurl;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
57
78
|
List<ArticleItem> sorts;
|
58
79
|
|
59
80
|
List<ArticleItem> builds = new List<ArticleItem>
|
@@ -92,4 +113,5 @@
|
|
92
113
|
}
|
93
114
|
|
94
115
|
|
116
|
+
|
95
117
|
```
|
3
全体的にわかりやすく修正。
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
主です。お2人方の助言のもと、無事にソートできるようになりました。
|
1
|
+
投稿主です。お2人方の助言のもと、無事にソートできるようになりました。
|
2
2
|
しかしソートをすると、今度はimgタグと画像URLのズレが起きてしまうのか、
|
3
3
|
画像がリンク切れ表示になってしまうようになりました;
|
4
4
|
今回の質問とは関係ないトラブルなので、また解決できないようでしたら別途質問させて頂きます・・・。
|
@@ -11,8 +11,9 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
|
14
|
-
<button class="btn btn-primary" @onclick="SortItems">Sort
|
14
|
+
<button class="btn btn-primary" @onclick="SortItems">Sort-名前昇順</button>
|
15
|
-
<button class="btn btn-primary" @onclick="SortItems2">Sort
|
15
|
+
<button class="btn btn-primary" @onclick="SortItems2">Sort-西暦降順</button>
|
16
|
+
<button class="btn btn-primary" @onclick="SortItems3">Sort-適当</button>
|
16
17
|
|
17
18
|
@if (sorts == null)
|
18
19
|
{
|
@@ -26,29 +27,29 @@
|
|
26
27
|
<span>@build.Number - @build.RegistrationDate</span>
|
27
28
|
<span>@build.Artist - @build.Title</span>
|
28
29
|
<span> @build.Description</span>
|
29
|
-
|
30
|
+
</a>
|
30
|
-
|
31
|
+
</li>
|
31
32
|
}
|
32
33
|
</ul>
|
33
34
|
}
|
34
35
|
else
|
35
36
|
{
|
36
|
-
<ul>
|
37
|
+
<ul>
|
37
|
-
|
38
|
+
@foreach (var sort in sorts)
|
38
|
-
{
|
39
39
|
{
|
40
|
+
{
|
40
|
-
|
41
|
+
<li class="sorts">
|
41
|
-
|
42
|
+
<a href="@sort.HtmlUrl">
|
42
|
-
|
43
|
+
<img src="/Images/sorts/@sort.ArtImage" style="width:100px; height:auto;
|
43
|
-
|
44
|
+
border:5px #ff0000 solid; margin:10px;" />
|
44
|
-
|
45
|
+
<span>@sort.Number - @sort.RegistrationDate</span>
|
45
|
-
|
46
|
+
<span>@sort.Artist - @sort.Title</span>
|
46
|
-
|
47
|
+
<span> @sort.Description</span>
|
47
|
-
|
48
|
+
</a>
|
48
|
-
|
49
|
+
</li>
|
50
|
+
}
|
49
51
|
}
|
50
|
-
}
|
51
|
-
</ul>
|
52
|
+
</ul>
|
52
53
|
}
|
53
54
|
|
54
55
|
@code {
|
@@ -56,11 +57,11 @@
|
|
56
57
|
List<ArticleItem> sorts;
|
57
58
|
|
58
59
|
List<ArticleItem> builds = new List<ArticleItem>
|
59
|
-
|
60
|
+
{
|
60
|
-
new ArticleItem(1, 800, "フェルメール", "真珠の耳飾りの少女", "綺麗系", "vermeer.jpg",
|
61
|
+
new ArticleItem(1, 800, "フェルメール", "真珠の耳飾りの少女", "綺麗系", "vermeer.jpg", "none"),
|
61
|
-
new ArticleItem(2, 1300, "ダ・ヴィンチ", "モナ・リザ", "凄み系", "mona_lisa.jpg",
|
62
|
+
new ArticleItem(2, 1300, "ダ・ヴィンチ", "モナ・リザ", "凄み系", "mona_lisa.jpg", "https://localhost:44391/mona_lisa"),
|
62
63
|
new ArticleItem(3, 1900, "作者不明", "タイトル不明", "謎", "unnamed.jpg", "none"),
|
63
|
-
new ArticleItem(4, 2100, "ダ・ヴィンチ", "最後の晩餐", "やたら大きい絵",
|
64
|
+
new ArticleItem(4, 2100, "ダ・ヴィンチ", "最後の晩餐", "やたら大きい絵", "the_last_supper.jpg", "none")
|
64
65
|
};
|
65
66
|
|
66
67
|
void SortItems()
|
@@ -75,4 +76,20 @@
|
|
75
76
|
sorts.Sort((a, b) => (b.RegistrationDate - a.RegistrationDate));
|
76
77
|
}
|
77
78
|
|
79
|
+
void SortItems3()
|
80
|
+
{
|
81
|
+
sorts = builds;
|
82
|
+
sorts.Sort((a, b) => string.Compare(a.Artist, b.Title));
|
83
|
+
}
|
84
|
+
|
85
|
+
// F5リロード関数 使わず。
|
86
|
+
NavigationManager NavigationManager;
|
87
|
+
|
88
|
+
private void HandleClick()
|
89
|
+
{
|
90
|
+
NavigationManager.NavigateTo("article001", true);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
|
78
95
|
```
|
2
改行ズレの修正。
answer
CHANGED
@@ -26,8 +26,8 @@
|
|
26
26
|
<span>@build.Number - @build.RegistrationDate</span>
|
27
27
|
<span>@build.Artist - @build.Title</span>
|
28
28
|
<span> @build.Description</span>
|
29
|
-
</a>
|
29
|
+
</a>
|
30
|
-
|
30
|
+
</li>
|
31
31
|
}
|
32
32
|
</ul>
|
33
33
|
}
|
@@ -39,8 +39,8 @@
|
|
39
39
|
{
|
40
40
|
<li class="sorts">
|
41
41
|
<a href="@sort.HtmlUrl">
|
42
|
-
<img src="/Images/sorts/@sort.ArtImage" style="width:100px;
|
42
|
+
<img src="/Images/sorts/@sort.ArtImage" style="width:100px; height:auto;
|
43
|
-
|
43
|
+
border:5px #ff0000 solid; margin:10px;" />
|
44
44
|
<span>@sort.Number - @sort.RegistrationDate</span>
|
45
45
|
<span>@sort.Artist - @sort.Title</span>
|
46
46
|
<span> @sort.Description</span>
|
@@ -57,10 +57,10 @@
|
|
57
57
|
|
58
58
|
List<ArticleItem> builds = new List<ArticleItem>
|
59
59
|
{
|
60
|
-
new ArticleItem(1, 800, "フェルメール", "真珠の耳飾りの少女", "綺麗系", "vermeer.jpg",
|
60
|
+
new ArticleItem(1, 800, "フェルメール", "真珠の耳飾りの少女", "綺麗系", "vermeer.jpg", "none"),
|
61
|
-
new ArticleItem(2, 1300, "ダ・ヴィンチ", "モナ・リザ", "凄み系", "mona_lisa.jpg",
|
61
|
+
new ArticleItem(2, 1300, "ダ・ヴィンチ", "モナ・リザ", "凄み系", "mona_lisa.jpg", "https://localhost:44391/mona_lisa"),
|
62
62
|
new ArticleItem(3, 1900, "作者不明", "タイトル不明", "謎", "unnamed.jpg", "none"),
|
63
|
-
new ArticleItem(4, 2100, "ダ・ヴィンチ", "最後の晩餐", "やたら大きい絵",
|
63
|
+
new ArticleItem(4, 2100, "ダ・ヴィンチ", "最後の晩餐", "やたら大きい絵", "the_last_supper.jpg", "none")
|
64
64
|
};
|
65
65
|
|
66
66
|
void SortItems()
|
1
if文の追加。
answer
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
主です。お2人方の助言のもと、無事にソートできるようになりました。
|
2
|
+
しかしソートをすると、今度はimgタグと画像URLのズレが起きてしまうのか、
|
3
|
+
画像がリンク切れ表示になってしまうようになりました;
|
4
|
+
今回の質問とは関係ないトラブルなので、また解決できないようでしたら別途質問させて頂きます・・・。
|
5
|
+
|
1
6
|
```Blazor
|
2
7
|
|
3
8
|
@page "/article001"
|