我有Web应用程序的默认页面,该页面重定向到其他组件,如下所示:
from fractions import Fraction
elif equation == 'slope':
slope = input("Do you need to find slope? Type 'yes' or 'no'.")
if slope == 'yes':
y2 = float(input("What's your y2 value?:"))
y1 = float(input("What is your y1 value?"))
x2 = float(input("What is your x2 value?:"))
x1 = float(input("What is your x1 value?:"))
m = y2-y1/x2-x1
print(str(m))
elif slope == 'no':
m = input("What is the slope?")
b = float(input("What is your y-intercept?"))
m = str(m)
b = str(b)
print("Your equation is: y = {}x + {}".format(m,b))
simplify = input("Do you want to simplify this to standard form? Type in 'yes' or 'no'")
if simplify == 'yes':
m = float(m)
b = float(b)
if m < 0:
pos_m = m*-1
if isinstance(b, float):
print(Fraction(b)) #Works, but not what I want
print(Fraction('b')) #Does not work
现在,如果我想从此处传递一些道具,例如仪表板页面,我该怎么做?我尝试了以下操作,但没有成功。
<script>
import page from "page";
import Form from "./Form.svelte";
import Dashboard from "./Dashboard.svelte";
let content = "";
page.base("/");
page("", function() {
content = Form;
});
page("dashboard", function() {
content = Dashboard;
});
page({
hashbang: true
});
</script>
答案 0 :(得分:2)
请参阅<svelte:component>
的文档。要传递任意道具,您可以使用属性传播:
onSelectionChange
这是一个实时示例:https://svelte.dev/repl/74593f36569a4c268d8a6ab277db34b5?version=3.12.1
这是一个官方示例(当前不展示传递道具):https://svelte.dev/examples#svelte-component